question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue on sample rate in Ubuntu 20.04, no audio

See original GitHub issue

Hello 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:open
  • Created 2 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
HaHehocommented, Jul 15, 2021

@HaHeho thank you. I was able to solve this by just making a new environment and installing everything from scratch, which is strange. If you want I can share the environment.yml 👍

Great. Sometimes environments can get a bit scrambled up when changing a lot of packages, I suppose (using conda and pip 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), so conda can figure out all cross-dependencies.

BTW, a new problem appeared on my machine. I am just able to sd.play(np.array, sr) with blocking=True method. If I don’t have that, it just sends clicks (sort of granular) alongside the ALSA lib pcm.c:8526:(snd_pcm_recover) underrun occurred print in the terminal. Any idea of what this might be?

Take a look in this thread and see if it already helps to solve the issue with sd.play() .

0reactions
luisArandascommented, Jul 15, 2021

Solved it! 👍 The sd.wait() function did it, now just need it not to stop the GUI forever, maybe go multithread. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sound not working on ubuntu 20.04
One of the recent kernel updates seems to have introduced an issue with some audio devices. The solution is to modify PulseAudio's default ......
Read more >
SoundTroubleshootingProcedure - Community Help Wiki
If sound is not working in both Windows and Ubuntu, please check your motherboard's manual to see if any jumpers are badly configured...
Read more >
How to Fix the No Sound Issue in Ubuntu - Make Tech Easier
When experiencing sound issues on your Ubuntu machine, you first need to is check out your headphones and speakers for connection problems. It ......
Read more >
How To Fix No Sound in Ubuntu And Linux Mint - It's FOSS
Speed dispatcher is the feature that allows your system to convert text to speech. Sometimes, it conflicts with other audio settings. If you...
Read more >
Bug #1966066 “audio from external sound card is distorted”
default-sample-rate to 48000, uncomment it by removing the semicolon ... InstallationMedia: Ubuntu 20.04.1 LTS "Focal Fossa" - Release amd64 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found