noisetorch / NoiseTorch

Real-time microphone noise suppression on Linux.
Other
9.36k stars 233 forks source link

Support for Echo Cancellation #24

Open gravypod opened 4 years ago

gravypod commented 4 years ago

I tested out this application and it is really good at removing noise. Unfortunately, in my current setup, I also have a lot of echo if I do not use headphones. I was wondering if you planned on adding support for echo cancellation to this application? I have a lot of echo in pretty much all software that does not support WebRTC's audio processing and echo cancellation.

Would incorporating this, or similar, be an eventual goal of this project?

Thanks for your time, hard work, and for open sourcing this!

lawl commented 4 years ago

Maybe, maybe not. Honestly don't know yet, but it's likely low priority.

marcmacmac commented 4 years ago

Echo cancellation is a pulseaudio module and shipped as default with all kinds of distributions, but eg on ubuntu it is disabled as default. Just add

load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1\ noise_suppression=1" source_name=echoCancel_source sink_name=echoCancel_sink
set-default-source echoCancel_source
set-default-sink echoCancel_sink

to your /etc/pulse/default.pa, restart (or pulseaudio -k) and use the new resulting device for NoiseTorch.

The combination of both results in an excellent result in video calls.

stevenpitts commented 4 years ago

@marcmacmac Thank you so much!!! I'm going to submit a PR to add this to the wiki and link it in the README edit: Apparently PRs to a Wiki isn't a thing on GitHub. Hmm.

lawl commented 4 years ago

Sorry for the slow reply. if anyone has this tested out and would like to write a wiki page, the easiest option may be to just write the markdown here into the issue and i'll copy it over.

stevenpitts commented 4 years ago

I've personally found that making it an executable file is better than adding it to default.pa, especially if your setup is designed to use multiple speakers/mics.

First, set the input and output devices to their base versions. Then, make sure the echo cancel module is unloaded (an error here isn't an issue):

pactl unload-module module-echo-cancel

Load the echo cancel module:

pactl load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1\ noise_suppression=1" source_name=echoCancel_source sink_name=echoCancel_sink

Set your output device to the echo cancelled sink:

pacmd set-default-sink echoCancel_sink

Stop any existing Noisetorch instance:

noisetorch -u

Start NoiseTorch with the echo cancelled source:

noisetorch -i -s "echoCancel_source"
lawl commented 4 years ago

Thanks, I've added this to the wiki here for now. But I'll leave this issue open. It might be nice to have NoiseTorch to this for you automatically by just checking a box in the future.

memtech3 commented 2 years ago

+1 for this feature, noise torch and echo canceling would be a great solution to my car computer's horrendous mic situation

lectrode commented 2 years ago

Here is a very simple bash script (updated 2024/01/10) based on the above commands to toggle the noisetorch+echo cancel sink on and off. It uses the presence of a sink named "echoCancel_sink" to determine if it is on or not.

#!/bin/bash
#toggles noisetorch with echo cancelation module-enabled virtual sink

chk(){ pactl list sinks short|grep echoCancel_sink >/dev/null && return 0; return 1; }

if chk; then
  #Unload
  noisetorch -u
  pactl unload-module module-echo-cancel
  if ! chk; then notify-send -i noisetorch -t 5 "Noisetorch OFF"
  else notify-send -i noisetorch -u critical "Failed to turn OFF Noisetorch"; fi
else
  #Load
  pactl load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1\ noise_suppression=1" source_name=echoCancel_source sink_name=echoCancel_sink
  pactl set-default-sink echoCancel_sink
  noisetorch -i -s "echoCancel_source" -t 70
  if chk; then notify-send -i noisetorch -t 5 "Noisetorch ON"
  else notify-send -i noisetorch -u critical "Failed to turn ON Noisetorch"; fi
fi
Spunkie commented 10 months ago

I have a bunch of people on windows that use krisp to be able to be on zoom meeting while still using their speakers without horrible echo. I wish I could direct people to noisetorch as a similar 1 click toggle solution to this issue when they are on linux.

I really hope this feature can be integrated directly into noisetorch soon.