Live data from Hacker News

Ask HN: How do browsers isolate internal audio from microphone input?

news.ycombinator.com

71–80 of 106 posts

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#71
post #13
post #7

The way this works (and I'm obviously taking a high level view here) is by comparing what is being played to what is being captured. There is an inherent latency in between what is called the capture stream (the mic) and the reverse stream (what is being output to the speakers, be it people taking or music or whatever), and by finding this latency and comparing, one can cancel the music from the speech captured. With…

It just seems more logical for the OS to do that, rather than the application. Basically every application that uses microphone input will want to do this, and will want to compensate for all audio output of the device, not just its own. Why does the OS not provide a way to do this?

There is a third place: a common library that all the apps use. If it is in the OS then it becomes brittle. If there's an improvement in the technology which requires an API change, that becomes difficult without keeping backwards compatibility or the previous implementation forever. Instead, there would be a newer generation common library which might eventually replace the first but only if the entire ecosystem chooses to leave the old one behind. Meanwhile there'd be a place for both. Apps that share use of a library would simply dynamically link to it.

This is the way things usually work in the Free Software world. For example: need JPEG support? You'll probably end up linking to libjpeg or an equivalent. Most languages have a binding to the same library.

Is that part of the OS? I guess the answer depends on how you define OS. On a Free Software platform it's difficult to say when a given library is part of the OS and when it is not.

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#72

Search for the compilation flag "CHROME_WIDE_ECHO_CANCELLATION" in the Chromium sources, and you will find your answer. Can't tell you anything else due to NDAs.

Thanks, I see it's a user toggle too chrome://flags#chrome-wide-echo-cancellation or edge://flags/#edge-wide-echo-cancellation . All these years I was praising my macbook, thinking it was the hardware doing the cancellation, but it was Chromium the whole time.

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#73
post #45

Earlier quoted context omitted.

> Why does the OS not provide a way to do this? Some do. But you need to have a strong-handed OS team that's willing to push everybody towards their most modern and highly integrated interfaces and sunset their older interfaces. Not everybody wants that in their OS. Some want operating systems that can be pieced together from myriad components maintained by radically different teams, some want to see their API's/inte…

> Some do Which Operating systems do this?

macOS has done this in recent versions. Similarly it will do all the virtual background and bokeh stuff for webcams outside of the (typically horrific) implementations in video conferencing apps.

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#74

"echo cancellation" is what its called, there's a few general purpose (non-ai) algos out there! What's really interesting is I can get the algorithm to "mess up" by using external speakers a foot or two away from my computer's mic! Just that little bit of travel time is enough to screw with the algo.

Echo cancellation is often disabled if you have headphones plugged in, under the assumption that headphones won't be audible in the microphone, and it's better to disable it to avoid it degrading your microphone signal. It might be that whatever program you're using doesn't know the difference between speakers and headphones (possibly because you're using the 3.5mm jack?)

jokes on them, some of us use the headphone jack

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#75
post #71
post #13

Earlier quoted context omitted.

It just seems more logical for the OS to do that, rather than the application. Basically every application that uses microphone input will want to do this, and will want to compensate for all audio output of the device, not just its own. Why does the OS not provide a way to do this?

There is a third place: a common library that all the apps use. If it is in the OS then it becomes brittle. If there's an improvement in the technology which requires an API change, that becomes difficult without keeping backwards compatibility or the previous implementation forever. Instead, there would be a newer generation common library which might eventually replace the first but only if the entire ecosystem cho…

> If it is in the OS then it becomes brittle

My experience is the opposite. When it's part of the OS, it's stable and you just say "you need OS version X or better" and it will just work. When it's a library, you eventually end up in dependency hell of deprecated libraries and differing versions (or worst case, the JavaScript ecosystem when the platform provides almost nothing and you get npm).

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#76
post #17
post #13

Earlier quoted context omitted.

It just seems more logical for the OS to do that, rather than the application. Basically every application that uses microphone input will want to do this, and will want to compensate for all audio output of the device, not just its own. Why does the OS not provide a way to do this?

How sure are you that Basically every application wants this? So should there be a flag at the os level for enabling the cancellation? How do you control that flag?

> How do you control that flag?

https://developer.apple.com/documentation/avfaudio/avaudiose...

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#77
post #5

This is something that is usually taken care of by the App that's receiving the input from the microphone (Google Meet, Teams, etc). The App breaks the audio into frequencies, and the ones that correspond to human voice ranges are accepted, and anything else is rejected. This is referred to as, for example, voice isolation, and has been turned on by default in all major meeting Apps for a little while now. Surprised…

Assuming OP is correct, your last sentence implies this isn't the solution being used. Additionally, many ( citation needed ) Youtube videos have people talking in them; this method wouldn't help with that. Isolating vocals in general is significantly more difficult than just relying on frequency range. Any instrument I can think of can generate notes that are squarely in the common range of a human (see: https://www…

Was trying to informally describe the use of Fourier transformations to achieve the isolation. Success will vary depending on the situation, but ML is also used in more recent cases with more uniform end results for the particular use case.

The initial question may be specific to the way one particular browser handles things to certain degree, but the comment was also trying to communicate that it can go beyond the browser and can actually be handled by the application. However, the microphone itself can also be participating at some level if it features noise suppression or some other enhancements.

The surprise about things being different when using a separate browser, come from assuming that any audio reaching the microphone should be processed equally if using FTs (or machine learning if applicable), so the audio source shouldn't matter.

References:

- https://www.nti-audio.com/en/support/know-how/fast-fourier-t...

- https://pseeth.github.io/public/papers/seetharaman_2dft_wasp...

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#78
post #13

Earlier quoted context omitted.

It just seems more logical for the OS to do that, rather than the application. Basically every application that uses microphone input will want to do this, and will want to compensate for all audio output of the device, not just its own. Why does the OS not provide a way to do this?

> Why does the OS not provide a way to do this? Some do. But you need to have a strong-handed OS team that's willing to push everybody towards their most modern and highly integrated interfaces and sunset their older interfaces. Not everybody wants that in their OS. Some want operating systems that can be pieced together from myriad components maintained by radically different teams, some want to see their API's/inte…

so something for systemD then?

Re: Ask HN: How do browsers isolate internal audio from microphone input?

#79
post #30

Earlier quoted context omitted.

This reminds me of: >The missile knows where it is at all times. It knows this because it knows where it isn't. By subtracting where it is from where it isn't, or where it isn't from where it is (whichever is greater), it obtains a difference, or deviation https://knowyourmeme.com/memes/the-missile-knows-where-it-is

https://www.youtube.com/watch?v=c8jWx2qmBWI

the missile is eepy https://youtu.be/Csp_OABIsBM
Post reply on HN