代码之家  ›  专栏  ›  技术社区  ›  Lee Probert

录制HTML音频时避免弹出和点击

  •  0
  • Lee Probert  · 技术社区  · 5 年前

    我正在开发一个应用程序,允许用户用麦克风录制消息,并使用一个名为 mic-recorder-to-mp3 .构造函数接受 bit-rate 当前正在进行的设置 128 (这应该足以进行语音记录)。

    我们已经开始用这个应用收集录音了,有些还可以,但有些却非常糟糕,因为它会发出巨大的点击声和砰砰声。

    我知道 sample-rate 无法设置,并且基于您使用的硬件,但是我还缺少其他东西吗?这个比特率太高了吗?我是否需要将更多内存设置到 AudioBuffer ? 非常感谢您的建议。

    0 回复  |  直到 5 年前
        1
  •  0
  •   Lee Probert    5 年前

    我高兴地发现,你现在可以在打电话时设置限制 getUsermedia 这可以提高录音质量。它们在网络音频规范中作为 MediaTrackConstraints : https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints

    用法:

    export const audioTrackConstraints = {
      echoCancellation: {exact: false},
      autoGainControl: {exact: false},
      noiseSuppression: {exact: false},
      sampleRate: 16000,
      }
    navigator.mediaDevices.getUserMedia({ audio: audioTrackConstraints})
    .then(() => {
      console.log('Permission Granted');
    })
    .catch((error) => {
      console.log(error.message);
    })