CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C++ (Non Visual C++ Issues) Ask or answer C and C++ questions not related to Visual C++. This includes Console programming, Linux programming, or general ANSI C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old July 17th, 2007, 11:07 PM
    stephenprogrammer07 stephenprogrammer07 is offline
    Member
     
    Join Date: Feb 2007
    Posts: 137
    stephenprogrammer07 is an unknown quantity at this point (<10)
    How to get Microsoft Speech SAPI to work in DEV C++ IDE

    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.

    Code:
    #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/d...displaylang=en

    speechsdk51msm.exe --- 131.5 MB



    Thanks in advance

    Stev

    Last edited by stephenprogrammer07; July 17th, 2007 at 11:24 PM.
    Reply With Quote
      #2    
    Old July 17th, 2007, 11:24 PM
    Paul McKenzie Paul McKenzie is offline
    Elite Member
    Power Poster
     
    Join Date: Apr 1999
    Posts: 20,400
    Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    Quote:
    Originally Posted by stephenprogrammer07
    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.
    Quote:
    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
    Reply With Quote
      #3    
    Old July 17th, 2007, 11:36 PM
    Paul McKenzie Paul McKenzie is offline
    Elite Member
    Power Poster
     
    Join Date: Apr 1999
    Posts: 20,400
    Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    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
    Reply With Quote
      #4    
    Old July 18th, 2007, 01:01 AM
    stephenprogrammer07 stephenprogrammer07 is offline
    Member
     
    Join Date: Feb 2007
    Posts: 137
    stephenprogrammer07 is an unknown quantity at this point (<10)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    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

    Last edited by stephenprogrammer07; July 18th, 2007 at 01:14 AM.
    Reply With Quote
      #5    
    Old July 18th, 2007, 01:48 AM
    Paul McKenzie Paul McKenzie is offline
    Elite Member
    Power Poster
     
    Join Date: Apr 1999
    Posts: 20,400
    Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    Quote:
    Originally Posted by stephenprogrammer07
    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.
    Quote:
    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]
    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.
    Quote:
    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.
    Quote:
    -- so you can imagine my frustration.
    Impatience is the word. Did you ever get a simple project to compile and debug first?
    Quote:
    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
    Reply With Quote
      #6    
    Old July 18th, 2007, 02:00 AM
    Paul McKenzie Paul McKenzie is offline
    Elite Member
    Power Poster
     
    Join Date: Apr 1999
    Posts: 20,400
    Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)Paul McKenzie has a reputation beyond repute (3000+)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    Here is the thread you didn't respond to:

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

    Regards,

    Paul McKenzie
    Reply With Quote
      #7    
    Old July 18th, 2007, 02:42 AM
    stephenprogrammer07 stephenprogrammer07 is offline
    Member
     
    Join Date: Feb 2007
    Posts: 137
    stephenprogrammer07 is an unknown quantity at this point (<10)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    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.
    Reply With Quote
      #8    
    Old December 17th, 2008, 10:43 PM
    infibit infibit is offline
    Junior Member
     
    Join Date: Jan 2008
    Posts: 3
    infibit is an unknown quantity at this point (<10)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    Quote:
    Originally Posted by stephenprogrammer07 View Post
    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.
    Reply With Quote
      #9    
    Old December 17th, 2008, 10:55 PM
    TheCPUWizard's Avatar
    TheCPUWizard TheCPUWizard is offline
    Elite / Microsoft MVP
    Power Poster
     
    Join Date: Mar 2002
    Location: NY, USA
    Posts: 12,095
    TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)TheCPUWizard has a reputation beyond repute (3000+)
    Re: How to get Microsoft Speech SAPI to work in DEV C++ IDE

    Quote:
    Originally Posted by infibit View Post
    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.....
    __________________
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:36 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009