Delphi calls Baidu speech recognition rest API
-20160616
-Thanks to the Magic Cat and Delphiteacher Brother's help to solve the problem of returning Chinese garbled!
-Note: The Voice recording format currently only supports the evaluation of Mono voice with 8k/16k sampling rate of 16bit bit depth
Compression format support: PCM (uncompressed), WAV, opus, Speex, AMR, X-flac
var surl, SLan, cuid, apiKey, Secretkey, token, sr:string;
Response:tstringstream; Stream:tfilestream;
Begin
//
SR: = ";
SLan: = ' zh ';//en en//x-flac
IdHttp.Request.ContentType: = ' audio/amr;rate=8000 ';
CUiD: = ' 392681 ';
apikey:= ' vah45xsaevxluk5ruwum4r1y ';
Secretkey: = ' Ogecx9oibaovylcywk1iotce9bbwejas ';
The following token is valid for 1 months and needs to be HTTP://YUYIN.BAIDU.COM/ASR for free registration upon expiration.
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
Delphi calls Baidu speech recognition rest API