没有输出......没有错误

时间:2013-04-29 20:57:21

标签: java c++ qt voice voice-recognition

我正在使用专为Java和C ++构建的 voce 语音识别API。以下是我的代码

#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;
}

当我运行此代码时,我什么都没得到!没有错误,没有输出,只是控制台窗口打开,并说“按返回退出”,这就是全部!以下是在QT控制台中打印的消息

Starting C:\Users\yohan\Documents\QTPeojects\Tired-build-Desktop_Qt_5_0_0_beta2_MSVC2010_32bit_SDK-Release\release\Tired.exe...
C:\Users\yohan\Documents\QTPeojects\Tired-build-Desktop_Qt_5_0_0_beta2_MSVC2010_32bit_SDK-Release\release\Tired.exe exited with code 0

voce.h 是一个API文件,您可以从此处获取。此头文件使用Jni将Java代码转换为C ++。 http://sourceforge.net/p/voce/code/HEAD/tree/src/c++/

请帮忙!

1 个答案:

答案 0 :(得分:0)

尝试在调试器中运行它。你的主要的第一行可能是失败的,只是在它出现时调用exit(0)。将调试语句放在它上面。

祝你好运。希望有所帮助。

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