我想在浏览器中实时播放 twilio 媒体流。为此,我使用 websocket 将 twilio 流从 node.js 服务器发送到浏览器。我正在使用 Wavefile npm 和以下代码转换 twilio 媒体流:-
// Server Side Code
const wav = new WaveFile();
wav.fromScratch(1, 8000, '8m', Buffer.from(item.audioPayload, "base64"));
wav.fromMuLaw();
wav.toSampleRate(44100);
let dataURI = wav.toDataURI();
item.audioPayload = dataURI;
this.sendAgentMessage(item, this.connection);
在浏览器端我正在使用这个播放音频:-
// Client side code
var snd = new Audio(message.audioPayload);
snd.play();
现在在播放音频时,我收到非常多的噪音和失真。
请帮我解决这个问题。
你找到解决方案了吗?