Skip to content

BUG: Sound device dont see record devices #592

@kleyton67

Description

@kleyton67

OS: Ubuntu 25.04 \n \l

Pipewire:
pipewire
Compiled with libpipewire 1.2.7
Linked with libpipewire 1.2.7

Wireplumber
wireplumber
Compiled with libwireplumber 0.5.8
Linked with libwireplumber 0.5.8

python_env:
conda
Python 3.10.18 (main, Jun 5 2025, 13:14:17) [GCC 11.2.0] on linux

recorder devices:

test_sounddevice.py:

import sounddevice as sd
import numpy as np

# Parameters
duration = 5  # seconds
sample_rate = 48000.0
channels = 2 # Stereo

print(sd.query_devices(kind='input'))

# arecord -l
sd.default.device=4
sd.default.samplerate = sample_rate 



input("something")
# Record audio
print("Recording...")
recording = sd.rec(int(duration * sample_rate), samplerate=sample_rate, blocking=True, channels=channels)
print("Recording finished.")

# Play back the recording
print("Playing back...")
sd.play(recording, sample_rate)
sd.wait()  # Wait until sound has finished playing
print("Playback finished.")

=============================================
First errors

  1. pip install sounddevice
  2. python test_sounddevice.py
    Error:
Traceback (most recent call last):
  File "yamnet_test/test_sounddevice.py", line 14, in <module>
    import sounddevice as sd
  File "sounddevice.py", line 72, in <module>
    _lib = _ffi.dlopen(_libname)
OSError: cannot load library 'libportaudio.so.2': miniconda3/envs/py_sounddevice/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /lib/x86_64-linux-gnu/libjack.so.0)

=============================================
Second error
1.conda install -c conda-forge sounddevice portaudio
2. python show
{'name': 'HDA Intel PCH: ALC295 Analog (hw:1,0)', 'index': 4, 'hostapi': 0, 'max_input_channels': 2, 'max_output_channels': 2, 'default_low_input_latency': 0.008, 'default_low_output_latency': 0.008, 'default_high_input_latency': 0.032, 'default_high_output_latency': 0.032, 'default_samplerate': 48000.0}

and play my song.
3. When i open gnome config page and run the script again, i got

python test_sounddevice.py 
Traceback (most recent call last):
  File "test_sounddevice.py", line 22, in <module>
    print(sd.query_devices(kind='input'))
  File "sounddevice.py", line 572, in query_devices
    raise PortAudioError(f'Error querying device {device}')
sounddevice.PortAudioError: Error querying device -1
  1. After 5 secs to close gnome audio config and start app again :
    {'name': 'HDA Intel PCH: ALC295 Analog (hw:1,0)', 'index': 4, 'hostapi': 0, 'max_input_channels': 2, 'max_output_channels': 2, 'default_low_input_latency': 0.008, 'default_low_output_latency': 0.008, 'default_high_input_latency': 0.032, 'default_high_output_latency': 0.032, 'default_samplerate': 48000.0}

  2. When i open an chromium page while 5 secs of recorder in the python script, i got:

{'name': 'HDA Intel PCH: ALC295 Analog (hw:1,0)', 'index': 4, 'hostapi': 0, 'max_input_channels': 2, 'max_output_channels': 2, 'default_low_input_latency': 0.008, 'default_low_output_latency': 0.008, 'default_high_input_latency': 0.032, 'default_high_output_latency': 0.032, 'default_samplerate': 48000.0}
something^[[A
Recording...
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1735
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1902
Expression 'PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2166
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2834
Traceback (most recent call last):
  File "test_sounddevice.py", line 33, in <module>
    recording = sd.rec(int(duration * sample_rate), samplerate=sample_rate, blocking=True, channels=channels)
  File "/py_sounddevice/lib/python3.10/site-packages/sounddevice.py", line 279, in rec
    ctx.start_stream(InputStream, samplerate, ctx.input_channels,
  File "/py_sounddevice/lib/python3.10/site-packages/sounddevice.py", line 2634, in start_stream
    self.stream = StreamClass(samplerate=samplerate,
  File "/py_sounddevice/lib/python3.10/site-packages/sounddevice.py", line 1440, in __init__
    _StreamBase.__init__(self, kind='input', wrap_callback='array',
  File "/py_sounddevice/lib/python3.10/site-packages/sounddevice.py", line 909, in __init__
    _check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
  File "/py_sounddevice/lib/python3.10/site-packages/sounddevice.py", line 2804, in _check
    raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening InputStream: Device unavailable [PaErrorCode -9985]

Questions:
There are some pipewire configuration to avoid this behavior?
There are any way to make clone in pipewire to be used on python?
Is it a problem with my conda env or libs required by sounddevice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions