vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

Pause listening vosk or microphone

Open mavericky87 opened this issue 2 years ago • 7 comments

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 avatar May 20 '22 05:05 mavericky87

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 avatar May 20 '22 05:05 mavericky87

@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

mavericky87 avatar May 23 '22 06:05 mavericky87

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

nshmyrev avatar May 24 '22 21:05 nshmyrev

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

apofisss1 avatar May 07 '24 15:05 apofisss1

Can you please explain at beginner level?

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

nshmyrev avatar May 07 '24 19:05 nshmyrev

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: @.***>

apofisss1 avatar May 07 '24 21:05 apofisss1

In test_microphone.py example

nshmyrev avatar May 08 '24 07:05 nshmyrev