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

Hide ALSA error output #182

Closed
chrisspen opened this issue Dec 10, 2016 · 10 comments
Closed

Hide ALSA error output #182

chrisspen opened this issue Dec 10, 2016 · 10 comments

Comments

@chrisspen
Copy link
Contributor

Every creation of Microphone() or listen() seems to generate the output:

ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave

which clutter my output and makes it difficult to read other output. Otherwise, the recognition code works flawlessly. I've tried swapping out sys.stdout and sys.stderr, but this is still output, implying it's happening from a system call. Is there an easy way to suppress these errors?

@Uberi
Copy link
Owner

Uberi commented Dec 11, 2016

Hi @chrisspen,

You can use the technique described in this StackOverflow answer to do what you want:

with noalsaerr() as n, Microphone() as source:
    ...

I wouldn't recommend using this (it would be better to make the ALSA configuration correct instead), but in a pinch, this should work fine.

@chrisspen
Copy link
Contributor Author

I also found removing the cards.pcm.* from my alsa.conf fixed some of the errors, and then explicitly entering the device_index for my microphone fixed the others. However, it's good to know about that context manager. Thanks.

@Trickery710
Copy link

import sounddevice

if you have to install it
pip3 install sounddevice

@Muszo
Copy link

Muszo commented Nov 8, 2023

import sounddevice

if you have to install it pip3 install sounddevice

Wow, that helped.
Can you please explain why importing a lib fixed the messages?

@OpenAyEye
Copy link

import sounddevice

if you have to install it pip3 install sounddevice

this is the answer. I don't know why, but it's the answer.
raspi 4 8gb bookworm raspbian

was getting alsa errors, jack errors, all sorts of errors,
i added
import sounddevice

all errors gone. if you're struggling on the raspi this is the answer.

@blokpardi
Copy link

import sounddevice solved it for me as well. Thanks @Trickery710!

@Speeder9743
Copy link

Wow @Trickery710, how does importing a lib fix all these stupid errors on the raspi?!

@Speeder9743
Copy link

import sounddevice
if you have to install it pip3 install sounddevice

this is the answer. I don't know why, but it's the answer. raspi 4 8gb bookworm raspbian

was getting alsa errors, jack errors, all sorts of errors, i added import sounddevice

all errors gone. if you're struggling on the raspi this is the answer.

Using the exact same os and pi board, @OpenAyEye !

@lstuma
Copy link

lstuma commented May 26, 2024

Wow @Trickery710, how does importing a lib fix all these stupid errors on the raspi?!

anybody found an answer, I'd be very interested

@renatocava
Copy link

I installed and imported the sounddevice library and the same output messages also stopped appearing. Just clarify that it is not an error, just messages that worry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants