Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a form based application in C# using Visual Studio 2015 that will recognize voice commands and speak accordingly. For example, if I say "Weather" it will speak out current weather of my location. If I say "News" it will read out news. Now I want to implement a "Stop" voice command that will stop whatever its speaking, remove all prompts that have been queued. I have tried couple of ways but its not working as expected. Can someone help to recognize "Stop" voice command while its already speaking?

What I have tried:

1. I am using SpeechRecognitionEngine object with Recognize() to recognize voice command and SpeechSynthesizer object with Speak() to speak text.

2. I have tried to handle "Stop" text in the sREngine_VoiceCommandRecognized event handle within if..else..if. But it comes to the if ( e.Result.Text == "Stop" ) section only after is has spoken all queued in prompts.

3. I have tried using two different SpeechRecognitionEngine objects with their respective event handlers for SpeechRecognition. The first object recognizes all voice commands except "Stop". The second SpeechRecognitionEngine recognizes only the "Stop" spoken word. In this case, when I say "Stop" the respective event handler is invoked only after it has finished speaking all current queued in prompts.

4. I have also tried using two threads and the mechanism mentioned in #3. In one thread first object calls Recognize() and recognizes all voice commands except "Stop". In the second thread, the second SpeechRecognitionEngine object calls the Recognize() and recognizes only the "Stop" spoken word. In this case, when I say "Stop" it recognizes it but the respective event handler is invoked only after it has finished speaking all current queued in prompts.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900