Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoactivate #5

Closed
Edesem opened this issue Jan 21, 2022 · 12 comments
Closed

Autoactivate #5

Edesem opened this issue Jan 21, 2022 · 12 comments
Labels
bug Something isn't working

Comments

@Edesem
Copy link

Edesem commented Jan 21, 2022

Switched from cadmus to this because I thought with a cli you can atleast autostart it, however following the config it it doesnt automatically pick my device.

config file at ~/.config/rnnoise_cli/rnnoise_cli.conf

[activate]

device = "alsa_input.usb-PreSonus_PreSonus_AudioBox_iOne_AB6C15021095-00.analog-stereo"

Ideally I would like to have rnnoise run with my .xinitrc and then automatically choose my microphone and then done.

Edit:
I wanted to say alongside this issue, I have noticed after use that the microphone begins to become out of sync over time, with roughly a 3 second delay after an hour or two. This is fixed by deactivating and reactivating but I've noticed that even when its freshly activate, there is an ever slight delay. I want to love this and if I can get it to automatically turn on when I turn on my pc that would be great. But hopefully this delay is an easy fix.

@IniasP
Copy link
Owner

IniasP commented Feb 5, 2022

Can you try that without the quotes? It should work that way.

As for the delay, I'm not immediately sure where that comes from. Maybe it has something to do with the sample rate. Both this and Cadmus use this and its readme says

48000 Hz audio input. Other sample rates may work, or not...

Cadmus always uses 48kHz for the null sink if I remember it correctly, while this application uses the sampling rate of the given device. Maybe just using 48kHz hardcoded is better after all.

I think this may be a lead if you can confirm you never experience this with Cadmus and whether you're using a microphone with a different sampling rate than 48kHz.
pactl list short sinks should show the sampling rate.

I have a 44100Hz device myself, I'll try leaving it on for a couple of hours and test whether using a 48kHz sink works.

IniasP added a commit that referenced this issue Feb 5, 2022
This may solve a sync issue (mentioned in #5) causing audio delay that increases with usage time
IniasP added a commit that referenced this issue Feb 5, 2022
This may solve a sync issue (mentioned in #5) causing audio delay that increases with usage time
IniasP added a commit that referenced this issue Feb 5, 2022
@Edesem
Copy link
Author

Edesem commented Feb 5, 2022

Ok it now works without the quotes, thank you, and I can have it autoload in my xinitrc meaning I automatically have a denoised microphone, so thats great.

I never experienced any delay on Cadmus. Doing pactl list short sinks it gives

0       alsa_output.pci-0000_01_00.1.hdmi-stereo        module-alsa-card.c      s16le 2ch 44100Hz       SUSPENDED 
1       alsa_output.pci-0000_00_1f.3.iec958-stereo      module-alsa-card.c      s16le 2ch 44100Hz       SUSPENDED 
4       bluez_sink.60_93_16_38_84_D1.a2dp_sink  module-bluez5-device.c  s16le 2ch 44100Hz       RUNNING 
7       rnnoise_mic_denoised_out        module-null-sink.c      s16le 2ch 44100Hz       RUNNING 
8       rnnoise_mic_raw_in      module-ladspa-sink.c    float32le 2ch 44100Hz   RUNNING 

so it turns out I have the same sample rate as you. Also doing it with cadmus loaded gives me this

0       alsa_output.pci-0000_01_00.1.hdmi-stereo        module-alsa-card.c      s16le 2ch 44100Hz       SUSPENDED 
1       alsa_output.pci-0000_00_1f.3.iec958-stereo      module-alsa-card.c      s16le 2ch 44100Hz       SUSPENDED 
4       bluez_sink.60_93_16_38_84_D1.a2dp_sink  module-bluez5-device.c  s16le 2ch 44100Hz       SUSPENDED 
9       mic_denoised_out        module-null-sink.c      s16le 2ch 44100Hz       RUNNING 
10      mic_raw_in      module-ladspa-sink.c    float32le 2ch 44100Hz   RUNNING 

so Idk but it seems like this implies that cadmus uses the same sample rate as the users microphone, although I could be wrong.

@IniasP
Copy link
Owner

IniasP commented Feb 5, 2022

My bad, I should've checked that. It seems like I was wrong and Cadmus just omits the rate argument where I determine it based on the device. I misremembered because the problem I faced in the past was the opposite, I think Cadmus will not work on a 48kHz mic because of this omission, as the default value is 44.1kHz.

Anyway, I found another promising lead.
werman/noise-suppression-for-voice recently added the following to their readme:

If you have problems with audio crackling or high / periodically increasing latency, adding latency_msec=1 to the loopback might help

Turns out Cadmus is already doing this and I must've thought it looked rather random/silly and of course at first sight it works just as well without it.

@IniasP
Copy link
Owner

IniasP commented Feb 5, 2022

Can you try installing from the latest main by cloning and running make install to see if 4d31461 fixed your delay issue?

IniasP added a commit that referenced this issue Feb 6, 2022
…d at the werman repo

Hopefully helps with #5 as well.
@IniasP IniasP added the bug Something isn't working label Feb 6, 2022
@Edesem
Copy link
Author

Edesem commented Feb 7, 2022

Can you try installing from the latest main by cloning and running make install to see if 4d31461 fixed your delay issue?

Your commits seems to have fixed the issue. Thank you for actually helping me, and creating something that I will probably be using for a long time now. It does exactly what I need and nothing more, nothing less. Thank you!

@Edesem Edesem closed this as completed Feb 7, 2022
@majedbawarshi
Copy link

@Edesem would you please guide me on how have you managed to run the plugin using the .xinitrc I am struggling to run the plugin using the systemd services, I've tried to run it directly from the service and I've tried to use the xinit in the services but nothing seems to work, I would appreciate it if you would help me out..

@Edesem
Copy link
Author

Edesem commented Feb 15, 2022

@Edesem would you please guide me on how have you managed to run the plugin using the .xinitrc I am struggling to run the plugin using the systemd services, I've tried to run it directly from the service and I've tried to use the xinit in the services but nothing seems to work, I would appreciate it if you would help me out..

I just put this line into my xinitrc before I run my window manager
rnnoise activate &
if you are using something else you may have to run that command somewhere else depending on your wm or de.

The important thing is you have your config file configured to automatically use the same device each time you run rnnoise activate

@Edesem Edesem mentioned this issue Feb 15, 2022
@majedbawarshi
Copy link

majedbawarshi commented Feb 15, 2022

Thank you for your reply, I tried your solution but it didn't work as well.. here is my xinitrc file content

#!/bin/sh

# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)

# invoke global X session script
rnnoise activate &
. /etc/X11/Xsession

every time I restart my PC I keep getting the following error shown in the attached picture
22

@Edesem
Copy link
Author

Edesem commented Feb 16, 2022

what is your OS and desktop environment/tiling window manager?

@majedbawarshi
Copy link

majedbawarshi commented Feb 16, 2022

I am using Ubuntu 20.04 LTS..
There is no ~/.xinitrc file in the OS by default, the .xinitrc exists in /etc/X11/xinit/xinitrc (I have added the previous post config there)..
Also, I tried to create a file in the home directory called .xinitrc but as expected, it didn't work...

Also, I would like to mention that I have created a systemd service inside my /etc/systemd/system directory to run it as a daemon process when the OS boots up,
Here is my service file content:

[Unit]
Description=Noise suppression service
After=systemd-user-sessions.service
[Service]
User=ss
Type=simple
Group=root
ExecStart=/bin/bash -c 'rnnoise activate'
TimeoutStartSec=1
[Install]
WantedBy=default.target

However, It doesn't work as well and produced some warnings

Here is the result of my sudo systemctl status noise-suppression.service

Şub 15 17:52:03 ss systemd[1]: Started Noise suppression service.
Şub 15 17:52:03 ss pulseaudio[1317]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Şub 15 17:52:03 ss pulseaudio[1317]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Şub 15 17:52:03 ss pulseaudio[1317]: [pulseaudio] module-loopback.c: No such source.
Şub 15 17:52:03 ss pulseaudio[1317]: [pulseaudio] module.c: Failed to load module "module-loopback" (argument: "source=auto_null.monitor sink=mic_raw_in channels=2 source_dont_move=true sink_dont_move=true latency_msec=1"): initialization failed.
Şub 15 17:52:03 ss bash[1282]: Activated!
Şub 15 17:52:03 ss pulseaudio[1317]: [pulseaudio] module.c: After module unload, module 'module-null-sink' was still loaded!
Şub 15 17:52:03 ss systemd[1]: noise-suppression.service: Succeeded.

As you have noticed it showed Activated! message between the warning lines but no rnnoise mic was produced

@Edesem
Copy link
Author

Edesem commented Feb 16, 2022

yeah xinitrc is usually for window managers but ubuntu does it in its own special way.

Try this https://askubuntu.com/questions/493632/automatically-run-a-command-on-start-up/493643#493643

@majedbawarshi
Copy link

thank you for your help, i managed to run the plugin on the os boot up using the following guide
https://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login

However, that's not my case..
I need to activate the plugin using the system service (Linux daemon) to control its status and to apply remote control on the plugin using the linux service..
I will move this discussion into here #8 for further discussion about running the plugin from the system service..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants