Click here to Skip to main content
15,867,308 members
Articles / Desktop Programming / MFC
Article

A Simple Speech Application Using SAPI 5.1 SDK

Rate me:
Please Sign up or sign in to vote.
3.24/5 (24 votes)
3 Oct 20042 min read 218.1K   39.5K   75   37
A simple speech application using SAPI 5.1 SDK.

Introduction

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 CSpeechDlg.

The steps involved are as follows:

  1. Initialize COM.
  2. Initialize the Recognizer (to recognize that a speech is being invoked).
  3. Initialize the RecoEngine (the Speech engine).
  4. Initialize the RecoContext (the context in which we are going to write the speech application).
  5. Set a user-defined message that will grab whenever something is spoken, to our window (here dialog).
  6. Set the speech record interest in RECOGNITION Status.
  7. Create the default audio input.
  8. Set the Input to the speech engine.
  9. Specify the Grammar that we want to use (here we use Dictation Grammar).
  10. Load the Dictation Tool.

Speech To Text

The 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 .

References

  • Microsoft Speech SDK 5.1.

Pre-Requisites

  • Microsoft Speech SDK 5.1 onwards.

My contact

Note

  • SAPI - Speech Application Programmer Interface.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
New Zealand New Zealand
Chakkaradeep, known as Chaks to his friends, hails from the Indian subcontinent.Having done his Masters in Software Engineering, he knows his way around a computer and has sound knowledge of Microsoft technologies.

Chaks is currently working as a Microsoft Developer @ New Zealand.

You can reach him via his blog - http://chakkaradeep.wordpress.com

Comments and Discussions

 
GeneralSpeech to text Pin
damodarm10-Jul-06 21:20
damodarm10-Jul-06 21:20 
GeneralInitialize COM Pin
Zyx Valinjee15-Jun-06 10:15
Zyx Valinjee15-Jun-06 10:15 
Generaladd own grammar lib Pin
TassadaqHussain16-Sep-05 10:52
TassadaqHussain16-Sep-05 10:52 
Generalvoice recognition Pin
TassadaqHussain14-Sep-05 8:07
TassadaqHussain14-Sep-05 8:07 
GeneralRe: voice recognition Pin
soumyasantadas29-Sep-07 16:59
soumyasantadas29-Sep-07 16:59 
GeneralRe: voice recognition Pin
TassadaqHussain29-Sep-07 23:08
TassadaqHussain29-Sep-07 23:08 
Generalspeech to text Pin
Cheeeeema17-Aug-05 10:13
sussCheeeeema17-Aug-05 10:13 
GeneralRe: speech to text Pin
chakkaradeepcc25-Aug-05 2:53
chakkaradeepcc25-Aug-05 2:53 
it is possible to convert speech into text....i think i have done this in this sample..please do check
GeneralRegarding "sphelper.h' Pin
chakkaradeepcc23-May-05 2:34
chakkaradeepcc23-May-05 2:34 
GeneralRe: Regarding "sphelper.h' Pin
mikkojay23-Feb-09 14:38
mikkojay23-Feb-09 14:38 
GeneralRe: Regarding "sphelper.h' Pin
khairul7863-May-11 17:42
khairul7863-May-11 17:42 
GeneralRelease Build Crashes Pin
Spoodles29-Nov-04 3:05
Spoodles29-Nov-04 3:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.