python-sounddevice
python-sounddevice copied to clipboard
No device list on raspberry pi
Hello I've implemented a code using the sounddevice library. Unfortunately there comes no list of the available hardware using the command python3 -m sounddevice, means that no hardware is detected? the installed libraries are: portaudio, libportaudio2, cffi, pyaudio, pygame Does anybody know what could be the reason? Maybe somethin with the alsa configurations?
Thank you!
Sorry, I have no idea.
Is there an error/warning message? Do other programs work? Does PyAudio work? How does the ALSA device list look like?
Hi thank you for your reply. Well i found the mistake i had an old library. Now i can run my programm but dont get any sound. I also tried the example code from the sounddevice homepage, but i do also not hear any sound here. example: play sine signal: https://python-sounddevice.readthedocs.io/en/0.3.14/examples.html
I really dont know what the problem could be. I neither get any sound via HDMI nor the audio jack.
Is there an error/warning message? Do other programs work? Does PyAudio work? How does the ALSA device list look like?
No I dont get any errors/warnings. Seems like the programm is running. I get an audio sound while using youtube for example. I havent tried pyAudio yet, and when i use the command pip -m sounddevice theres only coming <0 Alsa .. (in 2, out 0) my headphones do not occure. Is there another Alsa device list? or should i change sth in the alsa configurations?
Thank you so much
I havent tried pyAudio yet, and when i use the command pip -m sounddevice theres only coming <0 Alsa .. (in 2, out 0) my headphones do not occure.
Can you please post the actual command and the actual output? See also https://python-sounddevice.readthedocs.io/en/0.4.1/CONTRIBUTING.html#reporting-problems.
Is there another Alsa device list?
Yes.
Hi, my code is the example code from the sounddevice documentation for a sine signal. My output in the shell is: "press Return to quit" but I don't hear any sound..
import argparse
import sys
import numpy as np
import sounddevice as sd
start_idx = 0
try:
samplerate = sd.query_devices(args.device, 'output')['default_samplerate']
def callback(outdata, frames, time, status):
if status:
print(status, file=sys.stderr)
global start_idx
t = (start_idx + np.arange(frames)) / samplerate
t = t.reshape(-1, 1)
outdata[:] = args.amplitude * np.sin(2 * np.pi * args.frequency * t)
start_idx += frames
with sd.OutputStream(device=args.device, channels=1, callback=callback,
samplerate=samplerate):
print('#' * 80)
print('press Return to quit')
print('#' * 80)
input()
except KeyboardInterrupt:
parser.exit('')
except Exception as e:
parser.exit(type(e).__name__ + ': ' + str(e))
```
I don't know whether the code is relevant, but can you please format it properly anyway (see https://python-sounddevice.readthedocs.io/en/0.4.1/CONTRIBUTING.html#reporting-problems)?
And can you please answer the remaining unanswered questions from above?
Is there an error/warning message? No error/warning when I run the code.
Do other programs work? when I test the audio with aplay it works I hear sound
Does PyAudio work? Yes
How does the ALSA device list look like? python3 -m sounddevice <0, dmix, ALSA (0 in, 2 out)
My problem is, that I dont hear any sound using the sounddevice module. Other soundmodules work
Does PyAudio work?
Yes
OK, that's interesting.
What's the device list reported by PyAudio?
What PortAudio version does PyAudio use, and which one does the sounddevice module use?
How does the ALSA device list look like?
python3 -m sounddevice <0, dmix, ALSA (0 in, 2 out)
This still doesn't look like the exact output, but ignoring that, I guess we should expect at least more entries reported by sounddevice.
So what does the actual ALSA device list look like?
I discovered another odd thing in your original comment:
the installed libraries are: portaudio, libportaudio2, cffi, pyaudio, pygame
What is the portaudio package, where did it come from?
I would only expect libportaudio2.
The easiest one on a pi if you have a mic is the wire.py example and just run with -l to get the audio indexes. Seems to work fine on a Pi for me just have problems getting it to run with a loopback without distortion.
I am also having for ubuntu 18.04 LTS python3 -m sounddevice returns nothing
You guys are not using docker or a container or something?