vosk-api
vosk-api copied to clipboard
Modify for recognizing specific word
Hello, Your api is very useful. But I want to add a few more features, can you help?
- 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?
What is the specific usecase you have? Is it a homework?
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...?
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")