Issue on sample rate in Ubuntu 20.04, no audio
See original GitHub issueHello all. I am trying to listen to some numpy arrays generated from a neural net, and even following the steps of the recommended installation I always get the same error. Also, I noticed a problem when using the conda environment where I installed the libraries, is that I cannot see the “output” or “default” ALSA choice in soundcard.query_devices().
Currently it prints this error:
audio shape (31744,)
< 0 HDA NVidia: HDMI 0 (hw:0,3), ALSA (0 in, 8 out)
1 HDA NVidia: HDMI 1 (hw:0,7), ALSA (0 in, 2 out)
2 HDA NVidia: HDMI 2 (hw:0,8), ALSA (0 in, 8 out)
3 HDA NVidia: HDMI 3 (hw:0,9), ALSA (0 in, 8 out)
4 HDA NVidia: HDMI 4 (hw:0,10), ALSA (0 in, 8 out)
5 HDA NVidia: HDMI 5 (hw:0,11), ALSA (0 in, 8 out)
6 HDA NVidia: HDMI 6 (hw:0,12), ALSA (0 in, 8 out)
> 7 FCA1616: USB Audio (hw:1,0), ALSA (12 in, 0 out)
8 HD-Audio Generic: ALC892 Analog (hw:2,0), ALSA (2 in, 2 out)
9 HD-Audio Generic: ALC892 Alt Analog (hw:2,2), ALSA (2 in, 0 out)
10 hdmi, ALSA (0 in, 8 out)
11 input, ALSA (128 in, 0 out)
(1246976, 'PortAudio V19.7.0-devel, revision 147dd722548358763a8b649b3e4b41dfffbcfbb6')
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2050
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->playback, outParams, self->primeBuffers, hwParamsPlayback, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2724
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2845
<traceback>
File "/home/luis/anaconda3/envs/tensorflowpy37/lib/python3.7/site-packages/sounddevice.py", line 2738, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening OutputStream: Invalid sample rate [PaErrorCode -9997]
I’ve tried everything, from changing the sample rate, to completely reinstall this. still I’m not sure what is happening here. The interesting thing is that when I deactivate the environment I get more options in the devices array:
10 hdmi, ALSA (0 in, 8 out)
11 pulse, ALSA (32 in, 32 out)
12 input, ALSA (128 in, 0 out)
13 default, ALSA (32 in, 32 out)
But I can’t actually test this since I’m not able to install the libraries I have in the conda env in the $user. Any idea on how to solve this? Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (1 by maintainers)
Top GitHub Comments
Great. Sometimes environments can get a bit scrambled up when changing a lot of packages, I suppose (using
conda
andpip
inside is always a bit sketchy, since pip does not know what is going on outside). That’s why it’s good to setting up the environment with all packages simultaneously (like from a file), soconda
can figure out all cross-dependencies.Take a look in this thread and see if it already helps to solve the issue with
sd.play()
.Solved it! 👍 The sd.wait() function did it, now just need it not to stop the GUI forever, maybe go multithread. Thank you!