wwmm / easyeffects

Limiter, compressor, convolver, equalizer and auto volume and many other plugins for PipeWire applications
GNU General Public License v3.0
6.35k stars 266 forks source link

Feature request: Add Speex Noise supression #1792

Closed ZenurikSD closed 1 year ago

ZenurikSD commented 1 year ago

OBS has this filter for noise supression that works really well for just removing constant background noise without much loss in quality. As far as I'm aware, EasyEffects only has AI noise reduction which really tanks audio the quality with lower-end setups; it would be really nice to have this alternative.

wwmm commented 1 year ago

I will take a look at it. It may help in some of the cases where rnnoise doesn't work very well..

vchernin commented 1 year ago

I will take a look at it. It may help in some of the cases where rnnoise doesn't work very well..

Unfortunately part of the problem with rnnoise is it seems to be unmaintained.. e,g, there are potentially useful MRs open like this one with no response. https://gitlab.xiph.org/xiph/rnnoise/-/merge_requests/2

ZenurikSD commented 1 year ago

I will take a look at it. It may help in some of the cases where rnnoise doesn't work very well..

Thank you, I really appreciate it.

polarathene commented 1 year ago

Unfortunately part of the problem with rnnoise is it seems to be unmaintained

Not sure how this compares, but I saw it recently and will share here in-case it's of interest: nnnoiseless which says it's a Rust port of RNNoise (C library). Perhaps that's not relevant :sweat_smile:


These rnnoise models are a bit old, but I tried some from the recording category and noticed they handled filtering out some sounds better depending on what's important to you.

The speech recording model sh.rnnn for example didn't let through coughing (but likewise states it is focused on speech, so suppressing laughter would also apply), while bd.rnnn will let those sounds through and better suppress noises not related to voice (only minimal testing by myself so far).

NOTE: These models will show in EasyEffects UI when imported as bd or sh for example, there is no way to label them with something easier to identify and recall what it does differently such as Recording - Voice Optimized Model (bd) or Recording - Speech Optimized Model (sh).


That said a Gate usually works pretty well (I use one after Noise Suppression), and the suppression effect is reduced (at least with the standard model) while voice is detected for some duration (having a gate will ensure it's clipped sooner after speaking if necessary).

The suppression effect while speaking can sometimes be a bit too aggressive and muffle out or cut out audio (eg: music, which makes sense usually), but there is no way to toggle/adjust the "Noise Reduction" plugin while a Gate is open/closed AFAIK.


It'd be neat if we had a bit more configuration available, an alternative PipeWire plugin werman/noise-suppression-for-voice has a few that seem useful. Those settings all seem to support the first one for setting a voice detection threshold, effectively making it a simple Gate?

Presently you'd have to add a Gate after (which has more complex tunables), and that's not exactly the same as the the voice weighting threshold from RNNoise, which could better differentiate on content rather than dB (there was an update recently that added new tunables in Gate, I haven't considered those yet).

Digitalone1 commented 1 year ago

NOTE: These models will show in EasyEffects UI when imported as bd or sh for example, there is no way to label them with something easier to identify and recall what it does differently such as Recording - Voice Optimized Model (bd) or Recording - Speech Optimized Model (sh).

Change the file name and you will see the label you want.

wwmm commented 1 year ago

but I saw it recently and will share here in-case it's of interest: nnnoiseless which says it's a Rust port of RNNoise (C library). Perhaps that's not relevant sweat_smile

It is just a Rust wrapper for the rnnoise library we already use.

These models will show in EasyEffects UI when imported as bd or sh for example, there is no way to label them with something easier to identify and recall what it does differently such as Recording - Voice Optimized Model (bd) or Recording - Speech Optimized Model (sh).

Change the file name and you will see the label you want.

Or renaming the file before importing it.

Those settings all seem to support the first one for setting a voice detection threshold, effectively making it a simple Gate?

Probably not. Gates do not do special handling for voice. They seem to be doing some kind of pitch processing on top of rnnoise.

hch12907 commented 1 year ago

I added Speex support in my branch. (commit cba0d36d134d)

The GUI for it is very barebones since I have basically zero development experience with GTK4.

wwmm commented 1 year ago

I added Speex support in my branch. (commit https://github.com/wwmm/easyeffects/commit/cba0d36d134d948fc8b2aae4cde154e3478b3073)

@hch12907 it is a good start. Are you able to do a pull request? The changes are simple enough to add through copy and paste but through a pull request your contribution will be properly registered in our git history.

I am curious about two things. The first is the lack of configuration options. Is there none? The second is the use of a fixed block size. I did that for the rnnoise plugins because it requires a fixed sampling rate. And as a result resampling. So a fixed block size was easier to handle. But maybe speex does not need this.

hch12907 commented 1 year ago

@wwmm There are many configuration options: echo suppression, automatic gain control, dereverb, etc. I didn't include these in my initial commit since my main use-case for Speex support is the noise suppression (RNNoise + standard model works horribly with my laptop's built-in microphone and I sound like a robot with it turned on)

As for the fixed block size, I only did that because I followed the patterns in rnnoise.cpp. I will see what I can do.

wwmm commented 1 year ago

There are many configuration options: echo suppression, automatic gain control, dereverb, etc. I didn't include these in my initial commit since my main use-case for Speex support is the noise suppression (RNNoise + standard model works horribly with my laptop's built-in microphone and I sound like a robot with it turned on)

As for the fixed block size, I only did that because I followed the patterns in rnnoise.cpp. I will see what I can do.

I see. Our echo canceller is already based on speexdsp. So there is no need to add it here. Automatic gain control we also already have through libebur128. I will try to see if it makes sense to add the other features.

You can do the pull request as your code is right now. I can change the part about the block size after merging it. As I am used to it it is probably going to be easier for me to do this.

hch12907 commented 1 year ago

Created #1907.

You can do the pull request as your code is right now. I can change the part about the block size after merging it. As I am used to it it is probably going to be easier for me to do this.

Thanks!

wwmm commented 1 year ago

Our echo canceller is already based on speexdsp

Looking at speex docs it seems to be a different algorithm. The one we use right now from speexdsp requires probes connected to the microphone. Maybe there is a point in adding this control besides the one for noise suppression. But in this case it would probably be better to rename the new plugin from Noise Reduction (Fast) to something else. Maybe Speech Preprocessor

wwmm commented 1 year ago

speex_preprocess_run Returns: Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on.

I wonder how well this voice activity detection works. Maybe we should have an option for it too. I will do some tests.

wwmm commented 1 year ago

I think that SPEEX_PREPROCESS_SET_DENOISE is just a on/off toggle for the denoise algorithm and not a suppression level in dB.

wwmm commented 1 year ago

In this case we probably want SPEEX_PREPROCESS_SET_NOISE_SUPPRESS

wwmm commented 1 year ago

I think it makes sense to add the other controls. I will try to do that in the next days.

hch12907 commented 1 year ago

I think that SPEEX_PREPROCESS_SET_DENOISE is just a on/off toggle for the denoise algorithm and not a suppression level in dB.

Yeah, you are right. I got confused by Intellisense and chose the wrong constant.

wwmm commented 1 year ago

I have updated our master branch with voice detection controls.

Digitalone1 commented 1 year ago

It's hard to translate the new title of this plugin into my language.

I decided to do something like noise reduction for speex and noise removal/suppression for rnnoise which is more comprehensive in my language

At least, as I read from the manual, speex reduce the noise trying to improve the speech while rnnoise remove/suppress the noise affecting the speech also.

wwmm commented 1 year ago

I decided to do something like noise reduction for speex and noise removal/suppression for rnnoise which is more comprehensive in my language

I see. I renamed because with the additional controls noise reduction is just one feature among others.

hch12907 commented 1 year ago

My only concern is that people may not realise that Speech Processor provides an alternative noise reduction algorithm, but I don't have a better name for it either because it does more than just noise-cancelling.

Digitalone1 commented 1 year ago

My only concern is that people may not realise that Speech Processor provides an alternative noise reduction algorithm, but I don't have a better name for it either because it does more than just noise-cancelling.

That is my concern too. As I said, for Italian translation is even difficult to translate. I chose Noise Removal (or Noise Suppression) for Rnnoise and Noise Reduction for Speex.

wwmm commented 1 year ago

My only concern is that people may not realise that Speech Processor provides an alternative noise reduction algorithm, but I don't have a better name for it either because it does more than just noise-cancelling.

That is my concern too. As I said, for Italian translation is even difficult to translate. I chose Noise Removal (or Noise Suppression) for Rnnoise and Noise Reduction for Speex.

The problem with the solutions based on "Noise" is that they mean essentially the same thing. At least in Brazilian Portuguese something like Voice Processor or Voice detector would also be fine.

Digitalone1 commented 1 year ago

@wwmm really? Is there no translation to distinguish between a "removal" and a "reduction"?

That said, I suppose to have understood what both plugins are doing. Rnnoise (if you choose the proper model) can remove the noise, but it often can also cause a degradation of the speech.

Speex does not remove the noise completely (or at least it can be configured to do so, but it's not doing it as the default behaviour), but it focuses more on improving the speech. For this I was also thinking about using "Voice Enhancer".

If I didn't understand correctly, please tell me.

wwmm commented 1 year ago

really? Is there no translation to distinguish between a "removal" and a "reduction"?

There are different words in Brazilian Portuguese for "reduction" and "suppression". For the first it is "redução" and for the second "supressão". But when applied to this context in both cases we are talking about "making the noise level going to a lower value". They are almost synonyms in this situation. "Removal" can be translated as "remoção" and would give the idea of completely removing the noise. What may not happen with both plugins. And the one based on libspeex does more than just suppressing noise.

For this I was also thinking about using "Voice Enhancer".

In a way it does this when the noise is removed. It sounds fine in Brazilian Portuguese too.

Digitalone1 commented 1 year ago

Okay, so I will restore the previous translation for Rnnoise and use Voice Enhancer for Speex.

wwmm commented 1 year ago

Okay, so I will restore the previous translation for Rnnoise and use Voice Enhancer for Speex.

I imagine you mean renaming the label Speech Processor to Voice Enhancer. Or are you thinking about changing only the Italian translation? It is fine to change the English name too.

Digitalone1 commented 1 year ago

I imagine you mean renaming the label Speech Processor to Voice Enhancer. Or are you thinking about changing only the Italian translation? It is fine to change the English name too.

I changed the Italian translation because the translation of Speech Processor does not suggest in the best way that Voice is improved.

You decide what to do with Speex effect name. Do you want to change it?

wwmm commented 1 year ago

You decide what to do with Speex effect name. Do you want to change it?

Now that I saw that some people have already started to translate Speech Processor it is probably better to keep the name as it is.