stephenprogrammer07
July 17th, 2007, 11:07 PM
Hi;
I have been working on a c++ project with DevC++ IDE.
I decided to use the Microsoft Speech SAPI in my project. But couldn't get it to compile with Dev C++.
However it was trivial to get the code below to compiles in Visual Studio 2005. So I bought Visual Studio 2005 and tried to move all my code over to VIsual studio 2005. But there were too many other problems - problems i can't debug - can't get my program to run without error when compiled under Visual Studio.
So I'm going back to the drawing board and trying to figure out how to get the following speech code to compile under Dev C++ 4.9.9.2.
Here I have given you all the entire Code below.
If there is a Guru out there who can figure out how to compile this code in Dev C++ , I would really appreciate the solution.
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include <Servprov.h>
#include <sapi.h>
#include <string>
// SAPI Sample 1.cpp : Defines the entry point for the console application.
using namespace std;
ISpVoice* Voice = NULL; // The voice interface
int main ( int NumOfArguments, char** Argument )
{
// Initialize COM
CoInitialize ( NULL );
// Create the voice interface object
CoCreateInstance ( CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void**)&Voice );
//this is one technique to convert a char* to a WCHAR* which is the
//parameter & format that the Speak function will take.
/** getting this stuff to compile under Dev C++ is another problem
char* orig="this is just a test ";
size_t origsize = strlen(orig) + 1;
const size_t newsize = 53*2;
size_t convertedChars = 0;
wchar_t wcstring[newsize];
mbstowcs_s(&convertedChars, wcstring, origsize, orig, _TRUNCATE);
*/
//Alternatively, you can pass strTest if you don't want to use mbstowcs
const WCHAR* strTest = L"I'm trying to pass this in";
// Speak!
Voice -> Speak ( strTest , SPF_DEFAULT, NULL );
// Shutdown the voice
if ( Voice != NULL ) Voice -> Release (); Voice = NULL;
// Shutdown COM
CoUninitialize ();
return 0;
}
Here's the error that I'm getting:
in function 'main':
[Linker error] undefined reference to 'CoInitialize@4'
[Linker error] undefined reference to 'IID_ISpVoice'
[Linker error] undefined reference to 'CLSID_SpVoice'
[Linker error] undefined reference to 'CoCreateInstance@20'
[Linker error] undefined reference to 'CoUninitialize@0'
Id returned 1 exit status
[Build Error] Error 1
----------------------------------
Under Dev C++ Project Properties I have the following:
Under Includes:
D:\Program Files\Microsoft Speech SDK 5.1\Include
Under Libraries:
D:\Program Files\Microsoft Speech SDK 5.1\Lib\i386
D:\Program Files\Microsoft Speech SDK 5.1\IDL
D:\Program Files\Microsoft Speech SDK 5.1\Lib
D:\Program Files\Microsoft Speech SDK 5.1\Bin
Under Resource Directories I have:
D:\Program Files\Microsoft Speech SDK 5.1\IDL
D:\Program Files\Microsoft Speech SDK 5.1\Lib
D:\Program Files\Microsoft Speech SDK 5.1\Bin
You must have Windows Speech 5.3 installed - if it is installed, you will see the Speech Control Panel Applet in the Control Panel of your windows machine.
When you install the microsoft speech you will have all the content in those directories.
To install microsoft speech all you need is
http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86EC97-40A7-453F-B0EE-6583171B4530&displaylang=en
speechsdk51msm.exe --- 131.5 MB
Thanks in advance
Stev
I have been working on a c++ project with DevC++ IDE.
I decided to use the Microsoft Speech SAPI in my project. But couldn't get it to compile with Dev C++.
However it was trivial to get the code below to compiles in Visual Studio 2005. So I bought Visual Studio 2005 and tried to move all my code over to VIsual studio 2005. But there were too many other problems - problems i can't debug - can't get my program to run without error when compiled under Visual Studio.
So I'm going back to the drawing board and trying to figure out how to get the following speech code to compile under Dev C++ 4.9.9.2.
Here I have given you all the entire Code below.
If there is a Guru out there who can figure out how to compile this code in Dev C++ , I would really appreciate the solution.
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <windows.h>
#include <Servprov.h>
#include <sapi.h>
#include <string>
// SAPI Sample 1.cpp : Defines the entry point for the console application.
using namespace std;
ISpVoice* Voice = NULL; // The voice interface
int main ( int NumOfArguments, char** Argument )
{
// Initialize COM
CoInitialize ( NULL );
// Create the voice interface object
CoCreateInstance ( CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void**)&Voice );
//this is one technique to convert a char* to a WCHAR* which is the
//parameter & format that the Speak function will take.
/** getting this stuff to compile under Dev C++ is another problem
char* orig="this is just a test ";
size_t origsize = strlen(orig) + 1;
const size_t newsize = 53*2;
size_t convertedChars = 0;
wchar_t wcstring[newsize];
mbstowcs_s(&convertedChars, wcstring, origsize, orig, _TRUNCATE);
*/
//Alternatively, you can pass strTest if you don't want to use mbstowcs
const WCHAR* strTest = L"I'm trying to pass this in";
// Speak!
Voice -> Speak ( strTest , SPF_DEFAULT, NULL );
// Shutdown the voice
if ( Voice != NULL ) Voice -> Release (); Voice = NULL;
// Shutdown COM
CoUninitialize ();
return 0;
}
Here's the error that I'm getting:
in function 'main':
[Linker error] undefined reference to 'CoInitialize@4'
[Linker error] undefined reference to 'IID_ISpVoice'
[Linker error] undefined reference to 'CLSID_SpVoice'
[Linker error] undefined reference to 'CoCreateInstance@20'
[Linker error] undefined reference to 'CoUninitialize@0'
Id returned 1 exit status
[Build Error] Error 1
----------------------------------
Under Dev C++ Project Properties I have the following:
Under Includes:
D:\Program Files\Microsoft Speech SDK 5.1\Include
Under Libraries:
D:\Program Files\Microsoft Speech SDK 5.1\Lib\i386
D:\Program Files\Microsoft Speech SDK 5.1\IDL
D:\Program Files\Microsoft Speech SDK 5.1\Lib
D:\Program Files\Microsoft Speech SDK 5.1\Bin
Under Resource Directories I have:
D:\Program Files\Microsoft Speech SDK 5.1\IDL
D:\Program Files\Microsoft Speech SDK 5.1\Lib
D:\Program Files\Microsoft Speech SDK 5.1\Bin
You must have Windows Speech 5.3 installed - if it is installed, you will see the Speech Control Panel Applet in the Control Panel of your windows machine.
When you install the microsoft speech you will have all the content in those directories.
To install microsoft speech all you need is
http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86EC97-40A7-453F-B0EE-6583171B4530&displaylang=en
speechsdk51msm.exe --- 131.5 MB
Thanks in advance
Stev