Rikorose / DeepFilterNet

Noise supression using deep filtering
https://huggingface.co/spaces/hshr/DeepFilterNet2
Other
2.36k stars 219 forks source link

Ubuntu22.04 Pipewire #209

Closed StuartIanNaylor closed 1 year ago

StuartIanNaylor commented 1 year ago

Anyone got any ideas as think I got pipewire going as pipewire noob

pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 35
Server Protocol Version: 35
Is Local: yes
Client Index: 119
Tile Size: 65472
User Name: stuart
Host Name: ubuntu
Server Name: PulseAudio (on PipeWire 0.3.48)
Server Version: 15.0.0
Default Sample Specification: float32le 2ch 48000Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo
Default Source: alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.mono-fallback
pipewire -c ~/.config/pipewire/filter-chain.conf.d/deepfilter-mono-source.conf
2022-12-10T18:53:12.541Z | INFO |  df::tract | Init encoder with delay: 0
2022-12-10T18:53:12.542Z | INFO |  tract_linalg::x86_64_fma | mmm_f32, sigmoid_f32, tanh_f32: x86_64/fma activated
2022-12-10T18:53:12.542Z | INFO |  tract_linalg::x86_64_fma | mmm_i8_i8 and mmm_i8_i32: x86_64/avx2 activated
2022-12-10T18:53:12.574Z | INFO |  df::tract | Init ERB decoder with delay: 0
2022-12-10T18:53:12.602Z | INFO |  df::tract | Init DF decoder with delay: 0
2022-12-10T18:53:12.607Z | INFO |  df::tract | Running with model type deepfilternet2 lookahead 0
2022-12-10T18:53:12.607Z | INFO |  deep_filter_ladspa | Initialized DeepFilter Mono plugin
2022-12-10T18:53:12.607Z | INFO |  deep_filter_ladspa | DfMono::activate()
[E][00789.612323] pw.core      | [          core.c:  382 core_new()] 0x558a9bc05480: can't find protocol 'PipeWire:Protocol:Native': Operation not supported
[E][00789.612394] mod.filter-chain | [module-filter-ch: 1782 pipewire__module_init()] can't connect: Operation not supported
2022-12-10T18:53:12.608Z | INFO |  deep_filter_ladspa | DfMono::deactivate()
[E][00789.612868] pw.conf      | [          conf.c:  560 load_module()] 0x558a9b8e3190: could not load mandatory module "libpipewire-module-filter-chain": Operation not supported
[E][00789.613040] default      | [      pipewire.c:  123 main()] failed to create context: Operation not supported

Dunno went for Alsa as more used to it as struggling with pipewire on Ubuntu22.04

pcm.ladspa {
    type ladspa
    slave.pcm "plughw:1,0";
    path "/usr/lib/ladspa";
    plugins [{
        label deep_filter_mono
        input {
            control [ 100 ]
        }
    }]
}

pcm.deepfilter {
    type=plug
    slave = {
    pcm "ladspa"
    channels 1
    rate 48000}
}

Using the slave allows resampling but does anyone no how to turn off the info?

2022-12-10T22:33:54.645Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 1824. SNR: -11.7, Processing time:  1.2ms, RTF: 0.03
2022-12-10T22:33:54.646Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 48. SNR:   NaN, Processing time:  0.0ms, RTF: 0.00
Vad: 1.0 8.010172e-18 0.00015258792
2022-12-10T22:33:54.646Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 48. SNR:   NaN, Processing time:  0.0ms, RTF: 0.00
Vad: 1.0 2.1399882e-18 0.00015258792
2022-12-10T22:33:54.684Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 99. SNR:   NaN, Processing time:  0.0ms, RTF: 0.00
2022-12-10T22:33:54.685Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 1725. SNR: -12.4, Processing time:  1.2ms, RTF: 0.03
2022-12-10T22:33:54.686Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 48. SNR:   NaN, Processing time:  0.0ms, RTF: 0.00
Vad: 1.0 5.0252744e-18 0.00015258792
2022-12-10T22:33:54.686Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 48. SNR:   NaN, Processing time:  0.0ms, RTF: 0.00
Vad: 1.0 1.5208525e-17 0.00015258792
2022-12-10T22:33:54.725Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 1062. SNR: -11.2, Processing time:  0.6ms, RTF: 0.03
2022-12-10T22:33:54.725Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 762. SNR: -12.3, Processing time:  0.6ms, RTF: 0.04
2022-12-10T22:33:54.726Z | INFO |  deep_filter_ladspa | DfMono::run() enhanced frame with size 48. SNR:   NaN, Processing time:  0.0ms, RTF: 0.00

Even though its an alsa ladsap plugin the calling recording app gets all the filters stdout?

@Rikorose Is there a silent or quiet mode in the ladspa commands?

StuartIanNaylor commented 1 year ago

I am doing the same again @Rikorose Hendrik as libdeep_filter_ladspa.so is 10mb larger than the release version and apols but apart from cargo build --release I really struggle how to build for specifics with Rust. I guess I can just turn the logging to a much lower level and compile but once more just need the specific compile for the ladspa

Which do you recommend logging error or just off ?

Rikorose commented 1 year ago

You can silence the logging via the environmental variable RUST_LOG=ERROR. I will add some more documentation about this and also about compiling.

StuartIanNaylor commented 1 year ago

Cheers Hendrik PS I found a solution anyway as it gets lost in a pcm chain.

/etc/asound.conf

pcm.ladspa {
    type ladspa
    slave.pcm "agcin";
    path "/usr/lib/ladspa";
    plugins [{
        label deep_filter_mono
        input {
            control [ "Attenuation Limit (dB)" 28 ]
        }
    }]
}

pcm.deepfilter {
    type=plug
    slave = {
    pcm "ladspa"
    channels 1
    rate 48000}
}

pcm.agcin {
 type speex
 slave.pcm "plughw:1,0"
 agc 1
 agc_level 8000
 denoise no
 dereverb no
}

pcm.agcout {
 type speex
 slave.pcm "deepfilter"
 agc 1
 agc_level 8000
 denoise no
 dereverb no
}

Posting as well as using speexdsp on pre and post filter is working great with my KWS with no retraining of data. PS anyone using speex dsp not sure why as its absolutely ancient but rc1 of speex and speexdsp is installed in debians whilst asound_plugins expects the release so git clone the latest and gran the asound_plugins source and recompile. I did a bit of a rough howto on https://community.rhasspy.org/t/asound-conf-agc-denoise/1361 PS turn off denoise as its not in the same universe as DeepFilterNet

Also maybe due to be called via another process but RUST_LOG=ERROR doesn't work

Rikorose commented 1 year ago

Hm I run it via a pipewire user space process, so using env vars works here. FYI: You may also set envs for an alsa systemd service via the service file.

StuartIanNaylor commented 1 year ago

@Rikorose Hendrik would you give me the right build command as apols as after cargo build --release I can never seem to work out specifics but it produces a ladsap plugin about 10mb bigger than the release version so presume that is not right. I may hack out the log entries or maybe add another control to log or not?

Rikorose commented 1 year ago

You can look at the publish CI for the exact command: https://github.com/Rikorose/DeepFilterNet/blob/main/.github/workflows/publish.yml#L430

I also added instructions here: https://github.com/Rikorose/DeepFilterNet/tree/main/ladspa

The size may also depend on the exact commit. Since 0.3.1, the model has been updated so expect a different size.

Edit: The ladspa plugin should be around 25 MB again. Please update to latest main.

StuartIanNaylor commented 1 year ago

Doh now I am getting it so workflows/publish.yml is what I was looking for apols for my stupidity as it was there to be found.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.