alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.92k stars 1.1k forks source link

Pause listening vosk or microphone #969

Open mavericky87 opened 2 years ago

mavericky87 commented 2 years ago

hello I wanted some advice on how to solve a problem, everything works fine, vosk recognizes what I say and then a voice based on what I said, leaves to answer, if I wanted to disable the microphone or otherwise mute so that vosk does it pause while audio comes out of the speakers, and then resumes listening by vosk when the audio from the speakers is finished? All this on Raspberry with python, thank you very much :)

mavericky87 commented 2 years ago

because I want to avoid that vosk wastes time recognizing the words that come out of the speakers, and starts again when the answer and therefore the words from the speakers are finished, I have answers in mp3 that start based on what vosk recognizes example: vosk recognizes " what's the weather like today? " the mp3 starts with the answer on the weather, here I want that while the mp3 is in play, vosk goes to pause, and immediately afterwards starts listening again to recognize the words

mavericky87 commented 2 years ago

@nshmyrev excuse the tag if you have a tip for this as soon as you have time, thank you so much for the work you do

nshmyrev commented 2 years ago

Hi. Sorry, I missed this. If you don't want to pass audio to recognizer, just create a variable and if it is false, skip the audio before AcceptWaveform. You can modify variable from other thread. Like here:

https://github.com/alphacep/vosk-api/blob/master/python/example/test_microphone.py#L19

def callback(indata, frames, time, status):
    """This is called (from a separate thread) for each audio block."""
    if status:
        print(status, file=sys.stderr)
    if listening:
         q.put(bytes(indata))

then modify listening on and off

apofisss1 commented 5 months ago

@nshmyrev Hello, I have the same problem, but I did not understand what you wrote. Can you please explain at beginner level?

nshmyrev commented 5 months ago

Can you please explain at beginner level?

I can not. But you can ask questions if you have any

apofisss1 commented 5 months ago

def callback(indata, frames, time, status): """This is called (from a separate thread) for each audio block.""" if status: print(status, file=sys.stderr) if listening: q.put(bytes(indata))

where do we paste the code

Nickolay V. Shmyrev @.***>, 7 May 2024 Sal, 22:31 tarihinde şunu yazdı:

Can you please explain at beginner level?

I can not. But you can ask questions if you have any

— Reply to this email directly, view it on GitHub https://github.com/alphacep/vosk-api/issues/969#issuecomment-2099155049, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIKXBKQBB5V44TE7ZJCIDBLZBET2TAVCNFSM5WOIV2QKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBZHEYTKNJQGQ4Q . You are receiving this because you commented.Message ID: @.***>

nshmyrev commented 5 months ago

In test_microphone.py example