ricky0123 / vad

Voice activity detector (VAD) for the browser with a simple API
https://www.vad.ricky0123.com
Other
853 stars 138 forks source link

audio constraints applied before hard-coded constraints #28

Open cipherhell opened 1 year ago

cipherhell commented 1 year ago

https://github.com/ricky0123/vad/blob/cf567b65cace88917166afda526c9f12f6062b52/packages/web/src/real-time-vad.ts#L106

I was looking into custom audio constraints - if I read the code right, the constraints given by users is applied before hard-coded ones - so it's e.g. impossible to disable auto-gain. Is that right?

Unsure how to generate a pull request yet, but would you consider putting the ...this.options.additionalAudioConstraints, at the end of the audio constraints, or is autogain and noise suppression an absolute necessity for the vad library to work?

  init = async () => {
    if (this.options.stream === undefined)
      this.stream = await navigator.mediaDevices.getUserMedia({
        audio: {
          ...this.options.additionalAudioConstraints,
          channelCount: 1,
          echoCancellation: true,
          autoGainControl: true,
          noiseSuppression: true,
        },
      })
    else this.stream = this.options.stream
ricky0123 commented 1 year ago

Hi @cipherhell That is a good idea, although unfortunately I don't have any time to work on this project at the moment. The autogain and noise suppression are probably not a necessity.