WofWca / jumpcutter

⏩ Fast-forwards long pauses between sentences — watch lectures ~1.5x faster (browser extension)
https://chrome.google.com/webstore/detail/jump-cutter/lmppdpldfpfdlipofacekcfleacbbncp
GNU Affero General Public License v3.0
330 stars 11 forks source link

Better Voice Activity Detection (VAD) (volume threshold) algorithm? #46

Open WofWca opened 2 years ago

WofWca commented 2 years ago

Currently we're simply calculating the loudness of incoming audio and if it's below a certain value, we say it's silence. Would be cool to find a specialized algorithm that does this better, like what voice communication apps do. FYI in theory we can use an implementation written in a different language, such as C, C++, Rust, Go - we could compile it to WASM.

And it's not necessary to replace the current implementation, we can make an option to switch between different silence detection algorithms.

➕ Advantages:

➖ Disadvantages:

Where to start (I update the list from time to time):

Also see #164, there is a good collection of various VAD algorithms

I would appreciate your advice (as always).

I also found this: https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints/noiseSuppression Idk what it is, but may help. Also this: https://github.com/w3c/webrtc-extensions/issues/76

zznidar commented 2 years ago

I was thinking about doing some frequency comparison. Maybe by getting the ratio between certain frequencies inside human voice range and outside of it. Some research would be needed, though, to find the right values. Also, non-instrumental music would probably cause some problems.

WofWca commented 2 years ago

Finding an existing one would be cooler, at least in other languages, or at least in maths form.

Kj-is-escape commented 2 years ago

What exactly are we looking for, would something like webvoicesdk be it? the demo seems to do what we are looking for.

WofWca commented 2 years ago

What do you mean? The pros and cons in the issue description should give a rough idea. Have you looked further into tech specs of the library you suggested, how it's better than what we have now? Based on the demo it seems to also get activated by music. Anyway, thanks for suggestion.

Kj-is-escape commented 2 years ago

I didn't look much into it. "State of the art Recurent Neural Network that uses WebAssembly portable runtime for voice activity detection." gave me the idea that it was taking into account more than volume. I think "finding something that doesn't get activated by music" is a good way of measuring it.

WofWca commented 2 years ago

People who use NewPipe say that it does its job well (also it doesn't requre the user to specify volumeThreshold), so maybe copying their algorithm would be enough. It uses ExoPlayer, where the silence skipping feature is implemented:

https://github.com/google/ExoPlayer/blob/ab4d37f499ba49bb3cac7938eb03ebf7133ccfe6/library/core/src/main/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessor.java

Also see https://github.com/vantezzen/skip-silence/issues/36 (adaptive (dynamic) volume threshold)

WofWca commented 4 months ago

A few thoughts about OpenAI's Whisper (also mentioned in #164). I'm not an expert, but at a glance it looks to me like VAD with extra steps? I'm looking at FUTO Voice Input and they're using both Whisper and WebRTC VAD (check the "credits" section in their app:

WebRTC - Thanks to the voice activity detection to stop recognition on silence