标签: perceptual-sdk

将Visual C++控制台输出写入或复制到文本文件

我正在使用英特尔感知计算SDK语音识别模块.使用Microsoft Visual Studio 2012 Professional,SDK示例会感知听写,处理完语音输入后会在控制台窗口中打印出来.我想要做的就是复制打印在控制台窗口上的输出并将其写入.txt文件中.我遵循一般的方式,但不知何故文件中写的文字只是一些数字.

// Callback for recognized commands and alerts
class MyHandler: public PXCVoiceRecognition::Recognition::Handler, public    PXCVoiceRecognition::Alert::Handler 
Run Code Online (Sandbox Code Playgroud)

{public:MyHandler(std :: vector&commands){this-> commands = commands; }

virtual void PXCAPI OnRecognized(PXCVoiceRecognition::Recognition *cmd) 
{
  wprintf_s(L"\nRecognized: <%s>\n", (cmd->label>=0)?commands[cmd->label]:cmd-    >dictation); //this line prints the dictated statement//
  // writing to a text file
  printf("Writing to the txt file...");
  std::ofstream out("c:\\MyVoice.txt");
  out<<cmd->dictation;
}

protected:
std::vector<pxcCHAR*> commands;
Run Code Online (Sandbox Code Playgroud)

};

int wmain(int argc, wchar_t* argv[]) {
// Create session
PXCSmartPtr<PXCSession> session;
pxcStatus sts = PXCSession_Create(&session);
if (sts < …
Run Code Online (Sandbox Code Playgroud)

c++ include visual-c++ visual-studio-2012 perceptual-sdk

11
推荐指数
2
解决办法
2万
查看次数