# ALSA issue \`OSError: \[Errno -9997\] Invalid sample rate\`

**URL:** https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070
**Category:** This category is being retired - Support
**Created:** [November 11, 2018, 10:10am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070 "2018-11-11T10:10:21Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![KathyReid](https://community.openconversational.ai/user_avatar/community.openconversational.ai/kathyreid/32/1949_2.png) [@KathyReid](https://community.openconversational.ai/u/KathyReid)
#### Post date: [November 11, 2018, 10:10am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/1 "2018-11-11T10:10:21Z")

</div>

Over the past few days (around 4 days), we’ve received several reports of Mycroft, across multiple devices and distros being unable to understand audio input, often failing with the error;  
`OSError: [Errno -9997] Invalid sample rate`

We don’t know _why_ this is occurring, but @krisgesling has found a solution by editing `./asoundrc`, via [an Alexa issue](https://github.com/alexa/alexa-avs-sample-app/issues/277#issuecomment-253173323):

```auto
pcm.!default { type asym playback.pcm 
    { type plug slave.pcm "hw:0" } 
    capture.pcm { type plug slave.pcm "hw:1" } 
}

```

Please let us know if this works for you (and big ups @krisgesling)

---

<div class="post-metadata">

### Author: ![krisgesling](https://community.openconversational.ai/user_avatar/community.openconversational.ai/krisgesling/32/1432_2.png) [@krisgesling](https://community.openconversational.ai/u/krisgesling)
#### Post date: [November 11, 2018, 9:25pm UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/2 "2018-11-11T21:25:50Z")

</div>

In case anyone is using it in a multi-user situation, the asound config file can live at either:  
`~/.asoundrc` for a single user; or  
`/etc/asound.conf` as a system wide configuration.

---

<div class="post-metadata">

### Author: ![Klages](https://community.openconversational.ai/user_avatar/community.openconversational.ai/klages/32/1507_2.png) [@Klages](https://community.openconversational.ai/u/Klages)
#### Post date: [November 12, 2018, 7:55pm UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/3 "2018-11-12T19:55:34Z")

</div>

hi!  
i installed picroft for the first time today and had “error -9997”. my speakers worked but not the microphone (blue snowball). so i tried to edit ./asoundrc (it was empty?) but after that my speakers where not working anymore. it says now ./asoundrc is corrupted.  
i checked triple for spelling error but that was not the case, any idea on what went wrong here?

---

<div class="post-metadata">

### Author: ![KathyReid](https://community.openconversational.ai/user_avatar/community.openconversational.ai/kathyreid/32/1949_2.png) [@KathyReid](https://community.openconversational.ai/u/KathyReid)
#### Post date: [November 13, 2018, 9:18am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/4 "2018-11-13T09:18:36Z")

</div>

Hi there @Klages, can you please paste the contents of your `./asoundrc` file so we can just double check what’s in there?

---

<div class="post-metadata">

### Author: ![Klages](https://community.openconversational.ai/user_avatar/community.openconversational.ai/klages/32/1507_2.png) [@Klages](https://community.openconversational.ai/u/Klages)
#### Post date: [November 13, 2018, 9:56am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/5 "2018-11-13T09:56:34Z")

</div>

content of ./asoundrc :  
`pcm.!default { type asym playback.pcm { type plug slave.pcm "hw:0" } capture.pcm { type plug slave.pcm "hw:1" } }`

i did a fresh install 3 times and it was always the same result when i changed this file.

---

<div class="post-metadata">

### Author: ![KathyReid](https://community.openconversational.ai/user_avatar/community.openconversational.ai/kathyreid/32/1949_2.png) [@KathyReid](https://community.openconversational.ai/u/KathyReid)
#### Post date: [November 13, 2018, 10:24am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/6 "2018-11-13T10:24:04Z")

</div>

Thanks for confirming. That looks OK to me.  
Can you edit the file `/etc/.asoundrc` file and see if this works instead?

What is the specific error message that you are receiving?

---

<div class="post-metadata">

### Author: ![r0tekatze](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/r/5f8ce5/32.png) [@r0tekatze](https://community.openconversational.ai/u/r0tekatze)
#### Post date: [November 15, 2018, 8:23am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/7 "2018-11-15T08:23:19Z")

</div>

@KathyReid @krisgesling

Good catch.

For future reference, “hw:x,y” is a reference to first the card number, and then the device number. The appropriate values can be found by using `aplay -l` which outputs a list of audio devices attached to the system.

There is a minor issue with this approach in that it will fail unpredictably for those with USB input devices. This is because each time those devices are plugged in, their values can change. A solution to this is potentially to use a device _alias_ instead. Device aliases can be found by capitalising the appendix to the above aplay function - thus `aplay -L`. This outputs a list of device aliases, as well as friendly names, and what current HWID is attached to them.

If you want a better solution, you can write udev rules to ensure that a device gets the same HWID every time it is plugged in. This is advanced usage, so I won’t write it up here. Instead, here is some material on the same:

[http://reactivated.net/writing\_udev\_rules.html](http://reactivated.net/writing_udev_rules.html)  
[https://linux.die.net/man/8/udev](https://linux.die.net/man/8/udev)

---

<div class="post-metadata">

### Author: ![Gideon](https://community.openconversational.ai/user_avatar/community.openconversational.ai/gideon/32/1511_2.png) [@Gideon](https://community.openconversational.ai/u/Gideon)
#### Post date: [November 15, 2018, 11:29am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/8 "2018-11-15T11:29:51Z")

</div>

Hello, i’m new here and this is my first reply.

This solution worked for me. I had a fresh install on a Pi 3 with a Blue Snowball and got the [Errno -9997]

I used:

sudo nano ~/.asoundrc

–then i copy/pasted the text.

pcm.!default { type asym playback.pcm  
{ type plug slave.pcm “hw:0” }  
capture.pcm { type plug slave.pcm “hw:1” }  
}

ctrl+x to get out, (y) to confirm, and hit enter.

Did a sudo reboot and it worked.

Thanks a lot! It’s really nice here for a newbie.

---

<div class="post-metadata">

### Author: ![KathyReid](https://community.openconversational.ai/user_avatar/community.openconversational.ai/kathyreid/32/1949_2.png) [@KathyReid](https://community.openconversational.ai/u/KathyReid)
#### Post date: [November 15, 2018, 11:32am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/9 "2018-11-15T11:32:12Z")

</div>

Thanks so much for confirming it worked @Gideon, appreciate it

---

<div class="post-metadata">

### Author: ![clados](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@clados](https://community.openconversational.ai/u/clados)
#### Post date: [November 15, 2018, 2:42pm UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/10 "2018-11-15T14:42:00Z")

</div>

Hey everyone I just installed mycroft-core on Arch Linux for the first time and got the same sampling rate error when trying the audiotest module to resolve the error of not getting any mic input.

I’m using an usb headset with a microphone and its the default device for both input and output in pulseaudio.

I tried the fix recommended by this thread but it did not resolve the error for me.

What i did:

create the file ~/.asoundrc with the following content:

pcm.!default { type asym playback.pcm  
{ type plug slave.pcm “hw:2” }  
capture.pcm { type plug slave.pcm “hw:0” }  
}

I used the numbers 2 and 0 because the output of aplay -l looked the following:

card 2: Audio [HyperX 7.1 Audio], device 0: USB Audio [USB Audio]  
Subdevices: 1/1  
Subdevice #0: subdevice #0

Please let me know if I understood the explanation of @krisgesling wrong.

Appreciate any help.

---

<div class="post-metadata">

### Author: ![krisgesling](https://community.openconversational.ai/user_avatar/community.openconversational.ai/krisgesling/32/1432_2.png) [@krisgesling](https://community.openconversational.ai/u/krisgesling)
#### Post date: [November 19, 2018, 9:17am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/11 "2018-11-19T09:17:24Z")

</div>

Hi @clados, was the sound playing from your headphones? I think you might want:

```auto
    pcm.!default { 
    type asym playback.pcm { type plug slave.pcm “hw:2” }
    capture.pcm { type plug slave.pcm “hw:2” }
    }

```

This should set card 2 as both your playback and capture device.  
If you aren’t getting sound output, try setting your playback to another card, maybe:

```auto
    pcm.!default { 
    type asym playback.pcm { type plug slave.pcm “hw:0” }
    capture.pcm { type plug slave.pcm “hw:2” }
    }

```

The card/device definition that r0tekatze mentioned is a little different. I believe it defaults to device number 0 but you can make it explicit with “hw:2,0”. If you want to read more check out the [ALSA Project Documentation](http://www.alsa-project.org/main/index.php/Asoundrc), but let us know if this doesn’t work. Some people in the original thread needed to specify additional parameters like audio format.

---

<div class="post-metadata">

### Author: ![krisgesling](https://community.openconversational.ai/user_avatar/community.openconversational.ai/krisgesling/32/1432_2.png) [@krisgesling](https://community.openconversational.ai/u/krisgesling)
#### Post date: [November 19, 2018, 9:21am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/12 "2018-11-19T09:21:30Z")

</div>

Hi @Klages, did you have any luck with your microphone?  
If you’re still having trouble, let us know what output you get from running `aplay -l` in your terminal.

---

<div class="post-metadata">

### Author: ![Davi\_Ruela](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/d/8797f3/32.png) [@Davi\_Ruela](https://community.openconversational.ai/u/Davi_Ruela)
#### Post date: [November 21, 2018, 1:34pm UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/13 "2018-11-21T13:34:38Z")

</div>

I was geting the same error because, for some reason, pulse audio wasn’t installed. I installed it and now the microphone works.

---

<div class="post-metadata">

### Author: ![Seferi](https://community.openconversational.ai/user_avatar/community.openconversational.ai/seferi/32/1601_2.png) [@Seferi](https://community.openconversational.ai/u/Seferi)
#### Post date: [December 6, 2018, 5:29pm UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/14 "2018-12-06T17:29:46Z")

</div>

Hi, I have been having the same problem, getting the same error, output worked but input didnt. So I did a sudo apt-get install pulseaudio. Input started working but now output doesnt work… I appreciate if you could help. Thanks.

---

<div class="post-metadata">

### Author: ![KathyReid](https://community.openconversational.ai/user_avatar/community.openconversational.ai/kathyreid/32/1949_2.png) [@KathyReid](https://community.openconversational.ai/u/KathyReid)
#### Post date: [December 6, 2018, 5:43pm UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/15 "2018-12-06T17:43:49Z")

</div>

Hi @seferi, can you run `alsamixer` and try to select your output device there?

---

<div class="post-metadata">

### Author: ![KathyReid](https://community.openconversational.ai/user_avatar/community.openconversational.ai/kathyreid/32/1949_2.png) [@KathyReid](https://community.openconversational.ai/u/KathyReid)
#### Post date: [December 12, 2018, 10:25am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/17 "2018-12-12T10:25:32Z")

</div>

Hi there @Binabik, thanks so much for reporting this to us.

We currently have a PR that will include `pulseaudio` in the `autorun.sh` file as a requirement so once that is merged, `pulseaudio` will be a requirement for Picroft.

---

<div class="post-metadata">

### Author: ![Seferi](https://community.openconversational.ai/user_avatar/community.openconversational.ai/seferi/32/1601_2.png) [@Seferi](https://community.openconversational.ai/u/Seferi)
#### Post date: [December 26, 2018, 10:45am UTC](https://community.openconversational.ai/t/alsa-issue-oserror-errno-9997-invalid-sample-rate/5070/18 "2018-12-26T10:45:46Z")

</div>

Hi @KathyReid I run the alsamixer and the volume was all the way down. So I set the volume to maximum and start the mycroft again with ./start-mycroft.sh cli  
But it didn’t work, I tried changing sound cards on alsamixer with F6, didn’t work either. Is there perhaps a way to run the audio setup tool like in the initial setup at the beginning?
