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

Empty result for all_speakers/all_microphones on Ubuntu OS #176

Open
will46616 opened this issue Mar 1, 2024 · 6 comments
Open

Empty result for all_speakers/all_microphones on Ubuntu OS #176

will46616 opened this issue Mar 1, 2024 · 6 comments

Comments

@will46616
Copy link

Hi, I've installed soundcard module, but I ran soundcard.all_speakers() only get an empty list. Is there somthing wrong on my sound device?

@bastibe
Copy link
Owner

bastibe commented Mar 3, 2024

Is there any error message?

@will46616
Copy link
Author

I just got [] after runnning sc.all_speakers(), but I got some error message while running my code :
Exception ignored from cffi callback <function _PulseAudio.server_info..callback at 0x7f2a73e581f0>:
Traceback (most recent call last):
File "/home3/will/anaconda3/envs/MUSDB2/lib/python3.9/site-packages/soundcard/pulseaudio.py", line 211, in callback
info['default sink id'] = _ffi.string(server_info.default_sink_name).decode('utf-8')
File "/home3/will/anaconda3/envs/MUSDB2/lib/python3.9/site-packages/cffi/api.py", line 318, in string
return self._backend.string(cdata, maxlen)
RuntimeError: cannot use string() on <cdata 'char *' NULL>
Traceback (most recent call last):
File "/home3/will/BandSplitRNN-Pytorch-main/src/tt/test.py", line 39, in
with sc.get_microphone(id=str(sc.default_speaker().name), include_loopback=True).recorder(samplerate=SAMPLE_RATE) as mic:
File "/home3/will/anaconda3/envs/MUSDB2/lib/python3.9/site-packages/soundcard/pulseaudio.py", line 287, in default_speaker
name = _pulse.server_info['default sink id']
KeyError: 'default sink id'

Is this because there's no available speaker detected?

@bastibe
Copy link
Owner

bastibe commented Mar 4, 2024

it seems that pulseaudio does not return a default_sink name. There's probably something about your pulseaudio that is not properly set up.

@will46616
Copy link
Author

OK, thanks. I'll check my pulseaudio. Thank you for replying.

@will46616
Copy link
Author

Hi, now I can get audio loopback with soundcard and record it, but I have another question. Is it possible to keep using loopback with soundcard module? Just like using sounddevice.InputStream().

@bastibe
Copy link
Owner

bastibe commented Mar 12, 2024

Use the with-context manager, and keep recording for as long as you like.

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

2 participants