SoundCard icon indicating copy to clipboard operation
SoundCard copied to clipboard

Empty result for all_speakers/all_microphones on Ubuntu OS

Open will46616 opened this issue 11 months ago • 6 comments

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?

will46616 avatar Mar 01 '24 07:03 will46616

Is there any error message?

bastibe avatar Mar 03 '24 14:03 bastibe

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?

will46616 avatar Mar 04 '24 05:03 will46616

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

bastibe avatar Mar 04 '24 06:03 bastibe

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

will46616 avatar Mar 04 '24 07:03 will46616

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().

will46616 avatar Mar 07 '24 11:03 will46616

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

bastibe avatar Mar 12 '24 08:03 bastibe