获取access_token

1
2
3
4
5
6
7
8
9
10
11
12
13
14
https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id={API Key}&client_secret={Secret Key}

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store

{
"access_token": "1.a6b7dbd428f731035f771b8d********.86400.1292922000-2346678-124328",
"expires_in": 86400,
"refresh_token": "2.385d55f8615fdfd9edb7c4b********.604800.1293440400-2346678-124328",
"scope": "public",
"session_key": "ANXxSNjwQDugf8615Onqeik********CdlLxn",
"session_secret": "248APxvxjCZ0VEC********aK4oZExMB",
}

音频转码

要转码成16000采样率 16bits 位深的单声道pcm文件

1
-acodec pcm_s16le -f s16le -ac 1 -ar 16000 16k.pcm

提交pcm音频文件

1
2
3
4
5
6
7
http://vop.baidu.com/server_api
POST ?cuid=1111&token={access_token}
Host: vop.baidu.com
Content-Type: audio/pcm;rate=16000
Content-Length: 1000

{"err_no":0,"err_msg":"success.","corpus_no":"15984125203285346378","sn":"481D633F-73BA-726F-49EF-8659ACCC2F3D","result":["北京天气"]}