about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-06-25T03·01+0100
committertazjin <mail@tazj.in>2020-06-25T03·12+0000
commit6944d0c96a21a0033a7b2a49714e4e9e8522aabf (patch)
tree3a72c438883d46f1aa7b7d842836252d2cc674da /users
parent0e0e8d8ff4bc8b947ce0908e0e1e79b23db66754 (diff)
feat(tazjin/nsfv-setup): Add script for noise-cancelling others r/1080
This script creates a pulseaudio sink that will cancel noise in audio
streams sent to it, and then move it on to the default sink.

This means that other people's crackling, static background, gulping,
keyboard sounds, fan whirring, construction noise etc. are removed.

Some preliminary tests on TVL suggest that this actually works. The
parameter might need some tweaking ("50" is just the default value),
as there is some occasional crackling at the beginning/end of a speech
segment, but this is already *much* better than before.

Change-Id: I9d4e2b39cfc2b878b4b7c5458788b8d46fb801af
Reviewed-on: https://cl.tvl.fyi/c/depot/+/577
Reviewed-by: nyanotech <nyanotechnology@gmail.com>
Diffstat (limited to 'users')
-rw-r--r--users/tazjin/nsfv-setup/default.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/users/tazjin/nsfv-setup/default.nix b/users/tazjin/nsfv-setup/default.nix
new file mode 100644
index 0000000000..65f94034da
--- /dev/null
+++ b/users/tazjin/nsfv-setup/default.nix
@@ -0,0 +1,18 @@
+# Configures a running Pulseaudio instance with an LADSP filter that
+# creates a noise-cancelling sink.
+#
+# This can be used to, for example, cancel noise from an incoming
+# video conferencing audio stream.
+#
+# There are some caveats, for example this will not distinguish
+# between noise from different participants and I have no idea what
+# happens if the default sink goes away.
+{ pkgs, ... }:
+
+let
+  inherit (pkgs) ripgrep pulseaudio nsfv;
+in pkgs.writeShellScriptBin "nsfv-setup" ''
+  SINK=$(${pulseaudio}/bin/pacmd info | ${ripgrep}/bin/rg -r '$1' '^Default sink name: (.*)$')
+  echo "Setting up NSFV filtering to sink ''${SINK}"
+  ${pulseaudio}/bin/pacmd load-module module-ladspa-sink sink_name=NSFV sink_master=''${SINK} label=noise_suppressor_stereo plugin=${pkgs.nsfv}/lib/ladspa/librnnoise_ladspa.so control=50
+''