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 · 2 comments

Comments

Projects
None yet
2 participants
@chrisspen

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

This comment has been minimized.

Show comment
Hide comment
@Uberi

Uberi Dec 11, 2016

Owner

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.

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

This comment has been minimized.

Show comment
Hide comment
@chrisspen

chrisspen Dec 11, 2016

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.

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.

@chrisspen chrisspen closed this Dec 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment