Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can BufferStreamPlayer player amr steam? #190

Open
machine-w opened this issue Jul 17, 2023 · 2 comments
Open

can BufferStreamPlayer player amr steam? #190

machine-w opened this issue Jul 17, 2023 · 2 comments

Comments

@machine-w
Copy link

No description provided.

@xiangyuecn
Copy link
Owner

可以,关掉自动解码,在transform里面手动调用Recorder.AMR.decode进行解码成pcm,参考Recorder.amr2wav

@machine-w
Copy link
Author

testTransform=function(arrayBuffer,sampleRate,True,False){
var reader=new FileReader();
reader.onload=function(){
var amr=new Uint8Array(reader.result);
Recorder.AMR.decode(arrayBuffer,function(pcm){
Recorder({type:"pcm"}).mock(pcm,sampleRate).stop(function(wavBlob,duration){
True(wavBlob,duration);
},False);
},False);
};
reader.readAsArrayBuffer(new Blob([arrayBuffer]));
};
var socket = io('http://127.0.0.1:8085', {transports: ['websocket']});
socket.binaryType = 'arraybuffer';
stream=Recorder.BufferStreamPlayer({
decode:false, //传输过来的不是pcm就需要开启解码
play:true, //要播放声音,设为false不播放,只提供MediaStream
realtime:true,
transform:function(pcm,sampleRate,True,False){
console.log(pcm);
testTransform(pcm,sampleRate,function(pcm,sampleRate){
// True(pcm,sampleRate);
testSampleRate=sampleRate;
// testAllPcm.push(pcm);//另存一份 结束时转成一个完整音频 对比接收到的数据音质
},False);
}
});

报错:n.subarray is not a function at Object.decode (beta-amr.js:6:777)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants