Click to See Complete Forum and Search --> : How to get Microsoft Speech SAPI to work in DEV C++ IDE


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

Paul McKenzie
July 17th, 2007, 11:24 PM
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 you blame the compiler?

Why didn't you just fix the program? This should have been a very loud shout that you're programming was faulty and had bugs, and had nothing to do with 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.And what makes you think that Dev C++ will work differently? Your program will still have bugs.

Regards,

Paul McKenzie

Paul McKenzie
July 17th, 2007, 11:36 PM
Basically what I'm saying is this --

If you have a program compiled and linked for one compiler, and the program doesn't work, then there is one and only one thing that is valid to do -- fix the program then and there.

Going to another compiler is not going to work -- you will still have those very same bugs if and when you successfully compile and link for the other compiler. The worst case scenario is if the other compiler hides these bugs from you when you run the program. Then you're really in trouble since your program has turned into a time bomb ready to blow up at anytime you run the program differently, or on another machine, or if you add or remove code, or for any reason under the sun. No one would want to run a potentially unstable program.

The best bugs are bugs you can see for yourself and duplicate. Then they are just waiting to be addressed and fixed. Then you get to learn how to fix and address these issues. Visual C++ has one of the best debuggers for any environment, outshining and is more stable than what Dev-C++ has to offer.

Regards,

Paul McKenzie

stephenprogrammer07
July 18th, 2007, 01:01 AM
that's an interesting point.
Yes my code runs perfectly when compiled with Dev c++ - but in visual studio , here's the situation . (I was coding this app to Dev C++'s IDE for an entire year. )

NUMBER 1: The application is supposed to be pulling in an XML file using tinyXML, when I launch the application inside VS2005, the app says it can't load the XML file . But when I click the executable outside VS2005 it finds the XML file. - keep in mind the XML file is in the same place in both situations. The XML file is sitting right next to the executable in the filesystem.


NUMBER 2: If I click the executable outside of the VS2005 and it starts up properly by finding the XML file , when I click the X to shut down the program it gives me a Win32 exception that tries to open in the visual studio debugger.
Never had such a win32 execption error before. when I was using Dev C++.
(Although my only source for viewing such error with dev c++ was that I would notice zonealarm notifying me that dr. watson was being being accessed. However i didn't see that error any more )

NUMBER 3: It's telling me it compiled everything without debugging information - so basically it's just identifying the memory location of the exception which is not helping me single bit .

And it says it won't even open up the source code and point to the line with the error

-- so you can imagine my frustration.

I'm a complete newbie with VS2005. I just bought it with Hard-Earned Cash and installed it so I am not an expert. it has Tons of project properties -- way more than Dev c++.

Perhaps you better understand the challenges I face with VS2005. none of these problems happen with Dev. i thought it was the compiler and complexity of the VS environment settings.


I'm glad you mentioned the superiority of it's debugger -
I would sincerely appreciate if you could tell me how I can get the VS debugger to show me how my executable is related to my source code - so i can find line number where the exception happened - most-likely a pointer.

I would sincerely appreciate if you could guide me through figuring out why it can't find my XML file when running inside VS - but it finds out when clicking outside - the - the XML file is in the same directory with the executable.


Thanks in Advance
Stephen

Paul McKenzie
July 18th, 2007, 01:48 AM
that's an interesting point.
Yes my code runs perfectly when compiled with Dev c++ - but in visual studio , here's the situation . (I was coding this app to Dev C++'s IDE for an entire year. )

NUMBER 1: The application is supposed to be pulling in an XML file using tinyXML, when I launch the application inside VS2005, the app says it can't load the XML file . But when I click the executable outside VS2005 it finds the XML file. - keep in mind the XML file is in the same place in both situations. The XML file is sitting right next to the executable in the filesystem. Don't use relative path names. Use absolute path names. I don't see this being any kind of show-stopper whatsoever.
NUMBER 2: If I click the executable outside of the VS2005 and it starts up properly by finding the XML file , when I click the X to shut down the program it gives me a Win32 exception that tries to open in the visual studio debugger. Meaning your program is faulty when it does clean up.
[quote]Never had such a win32 execption error before. when I was using Dev C++. (Although my only source for viewing such error with dev c++ was that I would notice zonealarm notifying me that dr. watson was being being accessed. However i didn't see that error any more )Dr. Watson means that you're program has crashed. You don't just brush those aside.
NUMBER 3: It's telling me it compiled everything without debugging information - so basically it's just identifying the memory location of the exception which is not helping me single bit .And I mentioned this before in the thread that you never responded. You tried to create a project yourself without any experience whatsoever in the environment. You never took a step back and tried to create a simple console project first to get used to the environment.
-- so you can imagine my frustration. Impatience is the word. Did you ever get a simple project to compile and debug first?
Perhaps you better understand the challenges I face with VS2005. none of these problems happen with Dev. i thought it was the compiler and complexity of the VS environment settings. So why were you trying to use something that is complex without first trying something simple with the environment first??

Regards,

Paul McKenzie

Paul McKenzie
July 18th, 2007, 02:00 AM
Here is the thread you didn't respond to:

http://www.codeguru.com/forum/showthread.php?t=428643

Regards,

Paul McKenzie

stephenprogrammer07
July 18th, 2007, 02:42 AM
okay i'll try this approach.
I wasn't sure what kind of learning curve i would be looking at - in view of the time for me to finish this project.

infibit
December 17th, 2008, 10:43 PM
okay i'll try this approach.
I wasn't sure what kind of learning curve i would be looking at - in view of the time for me to finish this project.

Sir I am interested in learning speech recognition in devcpp.Could you please guide me with the procedure and a sample program?Hoping for a positive response.

TheCPUWizard
December 17th, 2008, 10:55 PM
Sir I am interested in learning speech recognition in devcpp.Could you please guide me with the procedure and a sample program?Hoping for a positive response.


On a thread that is over a year old (16 months)???? By a person who has not posted in over 2 months???

Hope you are not holding your breath.....