Saturday 11 January 2014

Now with Text-to-Speech and Speech Recognition

Adding text-to-speech was equally painless - I used the System.Speech.Synthesis library and added the below lines of code to wherever speech was required.  Now as you say a command it is repeated back via text-to-speech and displays it in the journal.

            // Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();

            // Configure the audio output.
            synth.SetOutputToDefaultAudioDevice();

            // Speak the recognised text passed to the recogniser event.
            synth.Speak(e.Result.Text);


About these videos:

To watch them in synchronisation start Arm Cam at 9 seconds and Computer Cam at 3 seconds.

Arm Cam: Speech controlled robotic arm with text-to-speech feedback

Computer Cam: Speech controlled robotic arm with text-to-speech feedback (no sound)

To help the speech recognition out I was toggling the mic between mute/un-mute and accidentally cut off part of the "wrist up"command, so it thought I said wrist down, quickly toggling the mic on again it picked up part of the text-to-speech repeating the command - this is why you hear "I have no idea what you said" which is triggered on the recognizer.SpeechRecognitionRejected event.  See the blooper at at 1:05 (Arm Cam).

Some links for further reading:
If you would like a copy of the full C# source code for my application let me know.
(Just in case you were wondering why the pink desk, its running on my daughters laptop!)

No comments:

Post a Comment