REST API 3300错误 帮我看一下
王尼玛丶png 发布于2017-11 浏览:1700 回复:4
0
收藏

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;
}

收藏
点赞
0
个赞
共4条回复 最后由用户已被禁言回复于2022-04
#5fujiayi1984回复于2017-11
#4 王尼玛丶png回复
一起扔是啥意思

我们有官方rest api demo的,请下载下,里面有JAVA示例

0
#4王尼玛丶png回复于2017-11

一起扔是啥意思

0
#3用户已被禁言回复于2017-11

输入参数不正确,请您仔细核对文档及参照demo,核对输入参数

0
#2goJhou回复于2017-11

speech要和len一起扔

0
TOP
切换版块