Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SAPI: Qt application is not "speaking"
Forum Updated to NodeBB v4.3 + New Features

SAPI: Qt application is not "speaking"

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yohan
    wrote on last edited by
    #1

    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!!!!

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      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!

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        Yohan
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved