You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

浏览器录音经socket.io传Node.js后回放速率异常,疑华硕D1声卡兼容问题

Audio Playback Distortion (Sudden Speed Spikes) Fixed: Asus D1 Sound Card Compatibility Issue

Hey folks, I ran into a weird audio glitch recently and wanted to share my solution in case anyone else gets stuck with the same problem.

Here's what was happening: I was recording audio in the browser using MediaRecorder, sending the generated Blob to a Node.js server via Socket.io, and saving the audio either to a MySQL database or as an .ogg file. But whenever I played back the audio—whether pulling it from the database or the saved file—I kept getting strange distortion: the sound would suddenly speed up at random intervals, then jump back to normal speed. I scoured through forums and documentation but couldn't find a fix at first.

Update: After testing across multiple devices, I realized this wasn't a code or server-side issue at all—it's a hardware/software compatibility problem with my Asus D1 sound card. When I recorded audio on other devices (like a laptop with built-in speakers or a different external audio interface), the playback was completely normal with no distortion.

For reference, here's the code I was using for recording and sending the audio:

var mediaRecorder;
var startRecord = function(recordData){
 if (!navigator.getUserMedia) navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
 if (navigator.getUserMedia) {
 navigator.getUserMedia({audio:true}, success, function(stream) {
 alert('Error capturing audio.');
 });
 } else alert('getUserMedia not supported in this browser.');
 function success(stream) {
 var chunks = [];
 mediaRecorder = new MediaRecorder(stream);
 mediaRecorder.start();
 mediaRecorder.onstop = function(e) {
 stream.getAudioTracks()[0].stop()
 var blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' })
 var audioURL = URL.createObjectURL(blob);
 if (recordData.id) {
 socket.emit('audio', { 'id':recordData.id, 'audio':blob, 'option':recordData.type });
 }
 mediaRecorder.ondataavailable = function(e) {
 chunks.push(e.data);
 }
 }
};
var stopRecord = function(recordData){
 mediaRecorder.stop();
 mediaRecorder.state = 'recording'
};

A quick takeaway: If you're dealing with unexpected audio playback issues, don't rule out hardware-specific quirks! Sometimes the problem isn't in your code, but in how your device's audio interface interacts with the browser's recording APIs.

内容的提问来源于stack exchange,提问作者MikeyB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:55:22