SAPI 5.1



  • Hallo

    Ich habe mir heute die Speech API von MS besorgt und installiert (unter win 7 64 Bit). In der Dokumentation bin ich auf folgendes Tutorial gestoßen und habe dies Implementiert. Jedoch funktioniert die Anwendung nicht und ich bin ziemlich verzweifelt bei der Fehlersuche...
    Zum Problem: Die Anwendung spricht nciht den String "Hello World" aus lässt sich aber ohne Fehler kompilieren.

    stdafx.h

    // stdafx.h : Includedatei für Standardsystem-Includedateien
    // oder häufig verwendete projektspezifische Includedateien,
    // die nur in unregelmäßigen Abständen geändert werden.
    //
    
    #pragma once
    
    #include "targetver.h"
    
    #include <stdio.h>
    #include <tchar.h>
    
    #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>
    

    main.cpp

    //
    
    #include "stdafx.h"
    #include <sapi.h>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char* argv[])
    {
        ISpVoice * pVoice = NULL;
    
        if (FAILED(::CoInitialize(NULL)))
            return FALSE;
    
        HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
        if(SUCCEEDED(hr))
        {
            hr = pVoice->Speak(L"Hello world", 0, NULL);
    		if(hr == S_OK)
    			cout << "success";
    		else
    			cout << "error: " << hr;
            pVoice->Release();
            pVoice = NULL;
    
        }
    
    	char a;
    	cin.get(a);
    
        ::CoUninitialize();
        return TRUE;
    }
    

    Folgende Implementierung gibt mir den Error Code: error: -2147221164 zurück
    hr = pVoice->Speak(L"Hello world", 0, NULL);
    if(hr == S_OK)
    cout << "success";
    else
    cout << "error: " << hr;



  • Hi, Ich hatte sowas auch mal.
    winerror.h
    // Klasse nicht registriert
    #define REGDB_E_CLASSNOTREG 0x80040154

    Da ich XP nutze, habs folgendes ausgeführt:
    start/run/cmd
    regsvr32 %windir%\Speech\Vdict.dll
    regsvr32 %windir%\Speech\VText.dll
    regsvr32 %windir%\Speech\WrapSAPI.dll
    regsvr32 %windir%\Speech\Xcommand.dll
    regsvr32 %windir%\Speech\Xlisten.dll
    regsvr32 %windir%\Speech\XTel.Dll
    regsvr32 %windir%\Speech\Xvoice.dll
    regsvr32 "C:\Programme\Gemeinsame Dateien\Microsoft Shared\Speech\sapi.dll"
    regsvr32 "C:\Programme\Gemeinsame Dateien\Microsoft Shared\SpeechEngines\MSCSR\wraplm.dll"
    regsvr32 "C:\Programme\Gemeinsame Dateien\Microsoft Shared\SpeechEngines\MSCSR\wrappc.dll"
    regsvr32 "C:\Programme\Gemeinsame Dateien\Microsoft Shared\SpeechEngines\MSCSR\wrapph.dll"


Anmelden zum Antworten