录制pcm代码如下:
recorder = getRecorderManager({
success(res) { console.log('getRecorderManager success ==>', res)},
fail(params) {console.log('getRecorderManager failure ==>', params) },
})
...
recorder.start({
sampleRate:16000,//采样率
numberOfChannels:1,//单声道
frameSize:1024*1024,
format:"pcm",
success(res) { console.log('startRecording success==>', res) },
fail(params) { console.log('startRecording fail ==>', params) }
})
Code: Select all
...
recorder.stop({
// recorder.current && recorder.current.stopRecording({
complete:()=>{
console.log("停止录音")
setAudioState(0)
},
success:(res)=>{
console.log("录音数据:",res)
if(res && res.tempFilePath){
uploadFile({//将pcm上传到服务器
url:HttpHost+"/api/AiBigModel/GetAudio",
filePath:res.tempFilePath,
name:"file",
complete:()=>{ },
success:(res)=>{
//...
},
fail:(res)=>{
//...
},
})
}
},
fail:(res)=>{
console.log("fail res:",res)
},
})