语音程序没有输出和错误

No output and no errors from Voce program

本文关键字:错误 输出 程序 语音      更新时间:2023-10-16

我正在使用 voice 语音识别API,这是为Java和c++构建的。下面是我的代码

#include "C:/Users/yohan/Documents/voce-0.9.1/src/c++/voce.h"
#include <iostream>
using namespace std;

int main(int argc, char **argv)
{
    voce::init("C:/Users/yohan/Documents/voce-0.9.1/lib", true, false, "", "");
    voce::synthesize("This is a speech synthesis test.");
    voce::synthesize("Type a message to hear it spoken aloud.");
    std::cout << "This is a speech synthesis test.  "
        << "Type a message to hear it spoken aloud." << std::endl;
    std::cout << "Type 's' + 'enter' to make the "
        << "synthesizer stop speaking.  Type 'q' + 'enter' to quit."
        << std::endl;
    std::string s;
    while (s != "q")
    {
        // Read a line from keyboard.
        std::getline(std::cin, s);
        if ("s" == s)
        {
            voce::stopSynthesizing();
        }
        else
        {
            // Speak what was typed.
            voce::synthesize(s);
        }
    }
    voce::destroy();
   // system("pause");
    return 0;
}

当我运行这段代码时,我一无所获。没有错误,没有输出,只是控制台窗口打开并说"按return to exit";这就是全部。以下是在QT控制台

中打印的消息
Starting C:UsersyohanDocumentsQTPeojectsTired-build-Desktop_Qt_5_0_0_beta2_MSVC2010_32bit_SDK-ReleasereleaseTired.exe...
C:UsersyohanDocumentsQTPeojectsTired-build-Desktop_Qt_5_0_0_beta2_MSVC2010_32bit_SDK-ReleasereleaseTired.exe exited with code 0

voice .h是一个API文件,你可以从这里获得它。这个头文件使用Jni,将Java代码转换为c++。http://sourceforge.net/p/voce/code/HEAD/tree/src/c + +/

尝试在调试器中运行它。main中的第一行可能失败,当失败时只调用exit(0)。在它上面也放一条调试语句。

好运。希望对你有帮助。

编辑:还要确保对库调用进行适当的错误检查。有时这需要try catch块,或者其他时候,只检查函数调用的返回值。