一直提示3301,音频质量错误。
//开始录音的时候
start: function () {
const options = {
duration: 60000,//指定录音的时长,单位 ms
sampleRate: 16000,//采样率
numberOfChannels: 1,//录音通道数
format: 'mp3'//音频格式,有效值 aac/mp3
}
//开始录音
recorderManager.start(options);
recorderManager.onStart(() => {
console.log('recorder start')
});
//错误回调
recorderManager.onError((res) => {
console.log(res);
})
},
后台识别基本设置
// 初始化一个Client
public static AipSpeech client = new AipSpeech(BaseStaticParameter.APP_ID, BaseStaticParameter.API_KEY,
BaseStaticParameter.SECRET_KEY);
SpeechResponse response = new SpeechResponse();
// 可选:设置网络连接参数
client.setConnectionTimeoutInMillis(2000); // 建立连接的超时时间(单位:毫秒)
client.setSocketTimeoutInMillis(60000); // 通过打开的连接传输数据的超时时间(单位:毫秒)
// 对语音二进制数据进行识别
org.json.JSONObject asrRes = client.asr(data, "pcm", 16000, null);