百度语音识别rest html,delphi调用百度语音识别REST API(示例代码)
delphi調用百度語音識別REST API
-20160616
-感謝 魔術貓 和 DelphiTeacher 兄的幫助解決了返回中文亂碼的問題!
-注:語音的錄音格式目前只支持評測8k/16k采樣率16bit位深的單聲道語音
壓縮格式支持:pcm(不壓縮)、wav、opus、speex、amr、x-flac
var sUrl, sLan, cuid, apiKey, secretKey, token, sR: string;
response: TStringStream; Stream: TFileStream;
begin
//
sR := ‘‘;
sLan := ‘zh‘;//en zh //x-flac
idHttp.Request.ContentType := ‘audio/amr;rate=8000‘;
cuid := ‘392681‘;
apiKey:= ‘vAH45xSaEVxluk5ruwUm4R1Y‘;
secretKey := ‘ogecx9OiBaovyLcYWk1iOTcE9bBWEjAs‘;
//下面這個token有效期1個月,過期后需要自己到http://yuyin.baidu.com/asr免費注冊申請
token := ‘25.e1bd734e752b559f3c710cd5cfa9c8ff.315360000.1781361290.282335-392681‘;
Stream := TFileStream.Create(‘e:\test0.amr‘, fmShareDenyNone);
Stream.Position := 0;
sUrl := ‘http://vop.baidu.com/server_api?lan=‘+sLan+‘&cuid=fireboxsoftsmartai&token=‘+token;
response := TStringStream.create(‘‘, tencoding.utf8);
idHttp.Post(sUrl, stream, response);
ShowMessage(response.DataString);
end;
總結
以上是生活随笔為你收集整理的百度语音识别rest html,delphi调用百度语音识别REST API(示例代码)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android扫码支付宝ofo,六大共享
- 下一篇: 支持html5特性的浏览器,HTML 5