String s = new String(Base64.encode(getBytes(MyApplication.VIDEO_PATH+"/audio_pcm.pcm"),Base64.DEFAULT));
RequestParams requestParams = new RequestParams("http://vop.baidu.com/server_api");
requestParams.addHeader(" Content-Type","application/json");
requestParams.addBodyParameter("format","pcm");
requestParams.addBodyParameter("rate","16000");
requestParams.addBodyParameter("channel","1");
requestParams.addBodyParameter("cuid",getIMEI(this));
requestParams.addBodyParameter("token",token);
requestParams.addBodyParameter("len",getBytes(MyApplication.VIDEO_PATH+"/audio_pcm.pcm").length+"");
requestParams.addBodyParameter("speech",s);
参数有问题吗
private byte[] getBytes(String filePath){
byte[] buffer = null;
try {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
byte[] b = new byte[1000];
int n;
while ((n = fis.read(b)) != -1) {
bos.write(b, 0, n);
}
fis.close();
bos.close();
buffer = bos.toByteArray();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return buffer;
}
我们有官方rest api demo的,请下载下,里面有JAVA示例
一起扔是啥意思
输入参数不正确,请您仔细核对文档及参照demo,核对输入参数
speech要和len一起扔