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

Modify for recognizing specific word

Open miziworld opened this issue 2 years ago • 3 comments

Hello, Your api is very useful. But I want to add a few more features, can you help?

  1. I want to print only when a specific word is recognized. For example, when the user says "red blue apple", I want to output the resulting text only when "blue" is included. ex) speak : red result : (nothing) speak : blue result : blue speak: red blue apple result: blue I am currently using test_microphone.py of the python example, and looking inside the code, the part that outputs the result seems to be the print(rec.Result()) part. Could you please tell me how to fix it?

miziworld avatar May 22 '22 13:05 miziworld

What is the specific usecase you have? Is it a homework?

nshmyrev avatar May 22 '22 13:05 nshmyrev

No, just for my personal experiment. I'll use this function on my robot or some devices that using the microphone on offline environment. Is it impossible to modify vosk-api for implementing that function...?

miziworld avatar May 23 '22 03:05 miziworld

You have to modify your code,not vosk api for that, like this:

result = json.loads(rec.Result())['text']
if "blue" in result:
     print ("blue")

nshmyrev avatar May 23 '22 06:05 nshmyrev