Click here to Skip to main content
13,767,491 members
Click here to Skip to main content
Add your own
alternative version


57 bookmarked
Posted 13 Sep 2002

Using Text to Voice Interfaces

, 13 Sep 2002
Rate this:
Please Sign up or sign in to vote.
Using Microsoft Text to Voice Interfaces in MFC

Sample Image


This article guides you to create a simple COM client using MFC, and following the same method we can create clients for any Component when a type library file (.tlb) is available.

Note: On any machines with Windows 2000 Installed check for a "Speech" folder under C:\WINNT. This folder contains all the necessary components to call speech engine.

So to start, fire up the VC++ 6.0 IDE and then select File->New, select the MFC AppWizard [exe] and Enter "SpeakText" as the Project name and save it in the required location. Select "Dialog Base" option and uncheck the "Document/View Architecture".

Design the user interface dialog as shown in the figure above using resource editor and name your dialog and its controls accordingly.

Note: In edit control properties, on the Styles tab select "Multiline" check box for typing multiple lines of text.

Add the following in "stdafx.h" to import the Voice Engine Component

#include 	// MFC support for Windows Common Controls

#import "C:\WINNT\Speech\vtxtauto.tlb" no_namespace

Compile "stdafx.cpp" file, which results in creation of two new files (1) vtxtauto.tlh, (2) vtxtauto.tli in the Debug/Release folder . These files give interface IVTxtAuto wrapper method implementations. Browse through SPEAKFLAGS structure present in vtxtauto.tlh and the other methods.

Now is the time to call the engine through the IVTxtAuto Interface. Add these variables in "SpeakTextDlg.h"

char sText[1000];	//a char array of required length
CLSID clsid;		//class id 
HRESULT hr;		//for holding results
IVTxtAuto *voicePtr; 	//a pointer to IVTxtAuto inteface

Add the following piece of code in OnInitDialog() function

	// Initializing COM
	hr = CoInitialize(NULL);
	//Getting the CLSID from Program name
	hr = CLSIDFromProgID(OLESTR("Speech.VoiceText.1"), &clsid);
	//Creating the instance of the Component
	hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, __uuidof(IVTxtAuto),

	if (FAILED(hr))
	   AfxMessageBox("Cannot Initialize Speech Engine");
	   return FALSE;
	   _bstr_t pszSite;
	   //Reqister function should be called first prior calling Speak function
	   //so that the application is registered for using voice engine
	   voicePtr->Speak("Welcome to Text to Voice Convertion Engine",vtxtsp_NORMAL);
	   voicePtr->Speak("Type your Text and ask me to speak",vtxtsp_NORMAL);

Add the following onclick handler for the "Speak" button

   GetDlgItemText(IDC_TEXT, sText, 200);

   if (0 == strcmp(sText,"\0") )
      voicePtr->Speak("What can i speak for you",vtxtsp_NORMAL);

Change the second parameter of Speak Function according  to the value of the SPEAKFLAGS structure present in vtxtauto.tlh. Add the following code for respective buttons

void CSpeakTextDlg::OnPause() 

void CSpeakTextDlg::OnResume() 


That's all. Build and Run the application.


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


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Questioni need vtxtauto.tlb Pin
zylosx25-Oct-07 0:25
memberzylosx25-Oct-07 0:25 
AnswerRe: i need vtxtauto.tlb Pin
newmetic25-Sep-08 0:50
membernewmetic25-Sep-08 0:50 
Generalruntime error!!! Pin
ghostdeath16-Oct-07 9:51
memberghostdeath16-Oct-07 9:51 
Questionvtxtauto.tlb? Pin
baekjinug17-Dec-06 15:06
memberbaekjinug17-Dec-06 15:06 
Generalcannot initialize speech engine! Pin
Mihai MOGA30-Mar-06 0:02
professionalMihai MOGA30-Mar-06 0:02 
QuestionHi,Can you help me? Pin
sinmorn24-May-04 15:37
membersinmorn24-May-04 15:37 
GeneralHelp Pin
sinmorn18-Apr-04 16:47
membersinmorn18-Apr-04 16:47 
Questionwhere is sphelper.h ? Pin
jbmyt30-Sep-03 9:10
memberjbmyt30-Sep-03 9:10 
QuestionWhy so complicate....??? Pin
Nikolai Teofilov28-Aug-03 2:36
memberNikolai Teofilov28-Aug-03 2:36 
Questioncan i get rid from the speech-sdk? Pin
FARTal_error4-Aug-03 11:19
memberFARTal_error4-Aug-03 11:19 
GeneralGreat work Pin
abhinaba28-Jul-03 20:38
memberabhinaba28-Jul-03 20:38 
QuestionSave as .wav? Pin
Gernot Frisch11-Apr-03 1:00
memberGernot Frisch11-Apr-03 1:00 
Generalfail to CLSIDFromProgID Pin
Eliran16-Feb-03 8:19
memberEliran16-Feb-03 8:19 
GeneralOther Language Pin
JLHJ11-Feb-03 10:59
memberJLHJ11-Feb-03 10:59 
GeneralSapi com object Pin
12-Nov-02 17:15
suss12-Nov-02 17:15 
GeneralRe: Sapi com object Pin
Anonymous18-Feb-03 9:46
memberAnonymous18-Feb-03 9:46 
GeneralRe: Sapi com object Pin
Wayne Scholar18-Feb-03 9:46
memberWayne Scholar18-Feb-03 9:46 
Questionis it possible to change the voice ? Pin
lolont17-Sep-02 4:39
memberlolont17-Sep-02 4:39 
GeneralWorked fine once! Pin
WREY16-Sep-02 23:10
memberWREY16-Sep-02 23:10 
GeneralRe: Worked fine once! Pin
cdr17-Sep-02 6:24
membercdr17-Sep-02 6:24 
GeneralRe: Worked fine once! Pin
Anonymous17-Sep-02 7:54
memberAnonymous17-Sep-02 7:54 
GeneralRe: Worked fine once! Pin
WREY17-Sep-02 11:57
memberWREY17-Sep-02 11:57 
GeneralRe: Worked fine once! Pin
lolont18-Sep-02 6:26
memberlolont18-Sep-02 6:26 
QuestionOther langage ? Pin
Anonymous16-Sep-02 1:00
memberAnonymous16-Sep-02 1:00 
GeneralOther Systems Pin
Ed Gadziemski15-Sep-02 4:38
professionalEd Gadziemski15-Sep-02 4:38 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06-2016 | 2.8.181116.1 | Last Updated 14 Sep 2002
Article Copyright 2002 by Jagadish.G
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid