This small speech application converts text to speech and speech to text. If you choose the "Speak" option, whatever you type in the textbox is is converted to speech and you can hear the Microsoft's default voice speaking it out!
This application also converts speech to text. Just connect your microphone and do the "Microphone Setup" to set up your microphone and speak. You will be able to see the words get typed in the textbox as you speak!
For best results please do try the Voice Training Wizard before speaking out anything, it helps in setting your grammar.
Using the Code
The application is a dialog based application written in MFC. It uses only one dialog class
The steps involved are as follows:
- Initialize COM.
- Initialize the Recognizer (to recognize that a speech is being invoked).
- Initialize the RecoEngine (the Speech engine).
- Initialize the RecoContext (the context in which we are going to write the speech application).
- Set a user-defined message that will grab whenever something is spoken, to our window (here dialog).
- Set the speech record interest in RECOGNITION Status.
- Create the default audio input.
- Set the Input to the speech engine.
- Specify the Grammar that we want to use (here we use Dictation Grammar).
- Load the Dictation Tool.
Speech To Text
CallBack function for our user defined message will perform the following for the speech to text conversion:
- It will process all the speech events.
- Check for the event ID generated to identify the speech event that has occurred.
- If it is the speech recognition event, then get the text and display it in the text area.
Text to Speech
This is a simple process, you just have to pass the text to a function
Speak(text) and now the function will take care of its processing .
- Microsoft Speech SDK 5.1.
- Microsoft Speech SDK 5.1 onwards.
- SAPI - Speech Application Programmer Interface.