1

I have a function that connects to my microphone and recognizes speech as a string with a phrase. It looks like this:

import json, pyaudio
from Analysis import Voice_tag, nlp
from vosk import Model, KaldiRecognizer

class VoiseRecorder():
    
    def __init__(self):
        model = Model("model1")
        self.rec = KaldiRecognizer(model, 128000)
        p = pyaudio.PyAudio()
        self.stream = p.open(format=pyaudio.paInt16, 
                            channels=1, 
                            rate = 128000, 
                            input=True, 
                            frames_per_buffer=64000)
        self.stream.start_stream()
        self.Voise
        for text in self.CamVoise():
            Voice_tag(text)
            print(" ")
            
        
    def Voise(self):
        print('F on')
        while True:
            data = self.stream.read(32000, exception_on_overflow=False)
            if (self.rec.AcceptWaveform(data)) and (len(data)>0):
                out = json.loads(self.rec.Result())
                if out['text']:
                    yield out['text']


VoiseRecord = VoiseRecorder()

Can I somehow transfer the sound from the rtsp stream to the processing using this method ?

Serega
  • 171
  • 8

0 Answers0