資源簡介
windows 訊飛語音聽寫 微軟sapi 離在線 語音識別
此應(yīng)用申請訊飛語音應(yīng)用已通過 完全原創(chuàng),僅供研究使用
適用于win7 及以上版本
點擊exe即可運行,無需配置環(huán)境
readme doc 相關(guān)開發(fā)和使用說明
本人在學(xué)校機(jī)器人基地負(fù)責(zé)語音模塊,相關(guān)問題請留言交流

代碼片段和文件信息
//?SpeechCloud.cpp?:?定義控制臺應(yīng)用程序的入口點。
//
#include?“stdafx.h“
#include?
#include?
#include?
//xunfei
#include“qisr.h“
#include“msp_cmn.h“
#include“msp_errors.h“
#include“msp_types.h“
//speech?spi
#include
#include
#include
#include
#ifdef?_WIN64
#pragma?comment(lib“msc_x64.lib“)?//x64
#else
#pragma?comment(lib“msc.lib“)?//x86
#endif
#define?HINTS_SIZE??100
void?get_result(const?char*?session_id)
{
int ????????????errcode?=?MSP_SUCCESS;
int aud_stat?=?MSP_AUDIO_SAMPLE_CONTINUE; //音頻狀態(tài)
int ep_stat?=?MSP_EP_LOOKING_FOR_SPEECH; //端點檢測
int rec_stat?=?MSP_REC_STATUS_SUCCESS; //識別狀態(tài)
char hints[HINTS_SIZE]?=?{?NULL?};?//hints為結(jié)束本次會話的原因描述,由用戶自定義
errcode?=?QISRAudioWrite(session_id?NULL?0?MSP_AUDIO_SAMPLE_LAST?&ep_stat?&rec_stat);
if?(MSP_SUCCESS?!=?errcode)
{
printf(“\nQISRAudioWrite?failed!?error?code:%d?\n“?errcode);
goto?iat_exit;
}
while?(MSP_REC_STATUS_COMPLETE?!=?rec_stat)?//讀取余下識別結(jié)果
{
const?char?*rslt?=?QISRGetResult(session_id?&rec_stat?0?&errcode);
if?(MSP_SUCCESS?!=?errcode)
{
printf(“\nQISRGetResult?failed?error?code:?%d\n“?errcode);
goto?iat_exit;
}
if?(NULL?!=?rslt)
{
printf(rslt);
}
Sleep(150);?//防止頻繁占用CPU
}
iat_exit:
QISRSessionEnd(session_id?hints);//
}
int?main(int?argc?char*?argv[])
{
int ret?=?MSP_SUCCESS;//
const?char*?login_params?=?“appid?=?563af3b7?work_dir?=?.“;?//?登錄參數(shù),appid與msc庫綁定請勿隨意改動
const?char*?session_begin_params?=
“sub?=?iat?domain?=?iat?language?=?zh_ch?accent?=?mandarin?sample_rate?=?16000?result_type?=?plain?result_encoding?=?gb2312“;
/*?用戶登錄?*/
ret?=?MSPLogin(NULL?NULL?login_params);?//第一個參數(shù)是用戶名,第二個參數(shù)是密碼,均傳NULL即可,第三個參數(shù)是登錄參數(shù)
if?(ret?==?MSP_SUCCESS)?{
printf(“登陸成功!\n“);
}
else?{
printf(“登陸失敗!?Error?code?%d.\n“?ret);
printf(“按任意鍵退出?...\n“);
getchar();
MSPLogout();?//退出登錄
return?0;
}
//----------------------------------------------------------------------------------
CoInitialize(NULL);??????????//?初始化COM
HRESULT?hr?=?S_OK;
CComPtr?cpVoice;???//?語音合成
CComPtr?cpRecognizer;????????//識別引擎
CComPtrjectToken>?cpobjectToken;
CComPtr?cpAudio;
CComPtr?cpRecoContext;
CComPtr?cpRecoGrammar;??????//識別語法
CComPtr?cpRetainedAudio;???//保存的音頻
CComPtr?cpRecoResult;????????//識別結(jié)果
const?SPSTREAMFORMAT?spFormat?=?SPSF_16kHz16BitMono;
CSpStreamFormat?Fmt(spFormat?&hr);?????????//?音頻采集&保存格式
ULONGLONG?ullMyEvents?=?SPFEI(SPEI_SR_RETAINEDAUDIO)?|?SPFEI(SPEI_SOUND_END)?|?SPFEI(SPEI_SOUND_START);
//要識別的事件.
HANDLE?hSpeechNotifyEvent?=?INVALID_HANDLE_VALUE;????????????//Win32?event
hr?=?cpRecognizer.CoCreateInstance(CLSID_SpInprocRecognizer);//識別引擎zh-CN
if?(SUCCEEDED(hr))?{
printf(“識別引擎初始化成功.\n“);
}
else?{
printf(“識別引擎初始化失敗!\n“);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????360??2016-05-13?20:09??readonline.asp
?????目錄???????????0??2016-04-02?20:09??SpeechCloud\
?????目錄???????????0??2016-04-01?15:35??SpeechCloud\.vs\
?????目錄???????????0??2016-04-01?15:35??SpeechCloud\.vs\SpeechCloud\
?????目錄???????????0??2016-04-01?15:35??SpeechCloud\.vs\SpeechCloud\v14\
?????文件???????27136??2016-04-02?19:43??SpeechCloud\.vs\SpeechCloud\v14\.suo
?????文件??????921467??2015-03-10?10:22??SpeechCloud\MSC?Novice?Manual?for?Windows.pdf
?????文件???????53760??2016-01-28?14:36??SpeechCloud\README.doc
?????文件?????????219??2016-04-01?15:01??SpeechCloud\README.txt
?????目錄???????????0??2016-04-02?19:21??SpeechCloud\SpeechCloud\
?????文件????????1315??2016-04-01?15:35??SpeechCloud\SpeechCloud.sln
?????目錄???????????0??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\
?????文件?????????352??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.log
?????文件??????278981??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.obj
?????目錄???????????0??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\
?????文件????????1454??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\CL.command.1.tlog
?????文件???????31812??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\CL.read.1.tlog
?????文件????????1620??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\CL.write.1.tlog
?????文件????????1424??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\li
?????文件????????3354??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\li
?????文件?????????686??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\li
?????文件?????????171??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\SpeechCloud.tlog\SpeechCloud.lastbuildstate
?????文件????????4218??2016-04-01?17:07??SpeechCloud\SpeechCloud\Debug\stdafx.obj
?????文件??????764928??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\vc140.idb
?????文件??????831488??2016-04-02?19:21??SpeechCloud\SpeechCloud\Debug\vc140.pdb
?????文件?????????541??2016-03-01?21:50??SpeechCloud\SpeechCloud\grammar.xm
?????目錄???????????0??2016-04-02?19:25??SpeechCloud\SpeechCloud\msc\
?????文件?????1823744??2016-02-29?17:06??SpeechCloud\SpeechCloud\msc.dll
?????文件???????13168??2015-09-23?09:20??SpeechCloud\SpeechCloud\msc.lib
?????文件???????23040??2016-04-02?19:25??SpeechCloud\SpeechCloud\msc\auth_local_check.log
?????文件???????19147??2016-04-02?18:39??SpeechCloud\SpeechCloud\msc\cloud_cisr1P1HaBHb6z1IWSW91aHkCgXCeGuoTdkd.log
............此處省略116個文件信息
- 上一篇:QT畫股市圖
- 下一篇:CMake 進(jìn)階
評論
共有 條評論