SAPI: Qt application is not "speaking"



  • Please have a look at the following code

    main.cpp

    @#define _ATL_APARTMENT_THREADED

    #include <atlbase.h>
    //You may derive a class from CComModule and use it if you want to override something,
    //but do not change the name of _Module
    extern CComModule _Module;
    #include <atlcom.h>

    #include <sapi.h>
    #include <iostream>

    using namespace std;

    int main(int argc, char* argv[])
    {
    cout << "Hello" << endl;
    ISpVoice * pVoice = NULL;

    if (FAILED(::CoInitialize(NULL)))
        return FALSE;
    
    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
    if( SUCCEEDED( hr ) )
    {
        cout << "Succeeded" << endl;
        hr = pVoice->Speak(L"Hello world", 0, NULL);
        cout << hr << endl;
    
        pVoice = NULL;
    }
    else
    {
        cout << "Not succeeded" << endl;
    }
    
    ::CoUninitialize();
    return TRUE;
    

    }

    @

    Speech.pro
    @
    #-------------------------------------------------

    Project created by QtCreator 2013-05-03T14:31:00

    #-------------------------------------------------

    QT += core

    QT -= gui

    TARGET = Speech
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    INCLUDEPATH += "C:/Program Files/Microsoft SDKs/Windows/v7.0A/Include"

    LIBS += "C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib/sapi.lib"
    LIBS += "C:/Program Files/Microsoft SDKs/Windows/v7.0A/Lib/User32.lib"

    @
    I am using windows 7, got to know SAPI is installed by default. I have downloaded SAPI 5.1 anyway. However, this code is not speaking!! No errors, nothing, the "suceed" message get printed, but no voice!

    The very beginning of the .cpp file is taken from MS website, where they advice it to put into "stdafx.h" in case of "Visual Studio" but VS 2010 also do not work properly to this since the advice is very old, and the "stdafx.h" auto generated is changed. It is a different story anyway.

    Why my code is not working? Please help!!!!


  • Moderators

    Hi Yohan,

    It looks like your issue is with the SAPI library, not the Qt library. If your program is compiling and linking with no errors, that means the Qt tools (qmake and Qt Creator) are working properly.

    You'll have better luck asking at the "Microsoft forums":http://social.msdn.microsoft.com/Forums. A few people have asked about SAPI here before, none of them managed to find answers; I don't think there's anyone with SAPI experience here unfortunately.

    Good luck!



  • Thanks for the reply. It is better to completely drop SAPI rather than contacting MS. I have created a profile, MS account, and post a question, and the question is not getting posted or deleted because "The account is not verified yet". Damn..
    [quote author="JKSH" date="1367665486"]Hi Yohan,

    It looks like your issue is with the SAPI library, not the Qt library. If your program is compiling and linking with no errors, that means the Qt tools (qmake and Qt Creator) are working properly.

    You'll have better luck asking at the "Microsoft forums":http://social.msdn.microsoft.com/Forums. A few people have asked about SAPI here before, none of them managed to find answers; I don't think there's anyone with SAPI experience here unfortunately.

    Good luck![/quote]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.