Python Forum
Microphone stream manipulation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Microphone stream manipulation
#1
Hello and happy new year!

I working with Vosk speech-to-text engine that already works but i want to improve the microphine input.

My thoughts are around:
- denoise stream
- gain stream

I've read much exaples but most one are just for wav files and not for microphone streaming

My code Looks lije this:
#!/usr/bin/env python3 import json import os import pyaudio from vosk import Model, KaldiRecognizer lang = en-US DEBUG = True class Vosk: def __init__(self, language): if not os.path.exists("models/vosk/" + language): print("Please download the model from https://alphacephei.com/vosk/models and unpack as " "'" + language + " ' in 'models/vosk'.") exit(1) model = Model("models/vosk/" + language) self.rec = KaldiRecognizer(model, 16000) p = pyaudio.PyAudio() self.stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=8000) self.stream.start_stream() def run(self): print("Listening...") while True: data = self.stream.read(4000) if len(data) == 0: break if self.rec.AcceptWaveform(data): res = json.loads(self.rec.FinalResult()) if DEBUG: print("Text:", res['text']) res = json.loads(self.rec.Result()) if DEBUG: print(res['text']) res = json.loads(self.rec.FinalResult()) if DEBUG: print("Listened: " + res['text']) return res['text'] if __name__ == '__main__': stt = Vosk(lang) print(stt.run())
I think right modules are audioop or Pydub but most examples are for WAV files...
Have you better ideas for right modules and then yes can you explain how i should work with the stream?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I stream and record at the same time with arducam? traderjoe 0 1,674 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  EEG stream data with mne and brainfolw PaulC 0 1,329 Aug-22-2023, 03:17 AM
Last Post: PaulC
  Create RTSP stream from camera? korenron 1 5,255 Jan-04-2022, 10:38 AM
Last Post: Larz60+
  Stream via socket with multiple clients principemestizo 0 3,701 Nov-01-2021, 06:25 PM
Last Post: principemestizo
  Decoding a serial stream AKGentile1963 7 15,729 Mar-20-2021, 08:07 PM
Last Post: deanhystad
  Best Video Quality And Stream Harshil 2 3,667 Aug-19-2020, 09:03 AM
Last Post: Harshil
  stream audio from pc to pc floatingshed 2 3,187 Sep-16-2019, 03:45 PM
Last Post: floatingshed
  pi camera stream is upside down delta1071 3 8,020 Sep-11-2019, 11:35 AM
Last Post: metulburr
  Need help to read a gzip stream... pythonchakri 5 6,090 Jun-07-2019, 02:33 AM
Last Post: heiner55
  Stream Data to Text or CSV format ekq378 0 3,410 Nov-16-2018, 06:32 PM
Last Post: ekq378

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.