我正在使用为 Java 和 C++ 构建的语音语音识别 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++/