# Cannot launch: Errno -9997 Invalid sample rate

**URL:** https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331
**Category:** This category is being retired - Support
**Created:** [October 3, 2021, 11:09pm UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331 "2021-10-03T23:09:48Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 3, 2021, 11:09pm UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/1 "2021-10-03T23:09:48Z")

</div>

Working on a Fedora 34 Linux server, fully up to date. USB microphone and regular speakers plugged into the headphone jack in front.

mycroft-start audiotest works correctly, recording and playing back my voice.

Yet mycroft does not work, and dies consistently on this error when running mycroft-cli-client:

19:01:35.146 | INFO | 874385 | mycroft.util.audio\_utils:find\_input\_device:196 | Searching for input device: iTalk-02: USB Audio  
19:01:35.149 | INFO | 874385 | mycroft.client.speech.listener:create\_wake\_word\_recognizer:328 | Creating wake word engine  
19:01:35.149 | INFO | 874385 | mycroft.client.speech.listener:create\_wake\_word\_recognizer:351 | Using hotword entry for hey mycroft  
19:01:35.150 | INFO | 874385 | mycroft.client.speech.hotword\_factory:load\_module:500 | Loading “hey mycroft” wake word via precise  
19:01:36.609 | INFO | 874385 | mycroft.client.speech.listener:create\_wakeup\_recognizer:365 | creating stand up word engine  
19:01:36.610 | INFO | 874385 | mycroft.client.speech.hotword\_factory:load\_module:500 | Loading “wake up” wake word via pocketsphinx  
Expression ‘paInvalidSampleRate’ failed in ‘src/hostapi/alsa/pa\_linux\_alsa.c’, line: 2043  
Expression ‘PaAlsaStreamComponent\_InitialConfigure( &self-\>capture, inParams, self-\>primeBuffers, hwParamsCapture, &realSr )’ failed in ‘src/hostapi/alsa/pa\_linux\_alsa.c’, line: 2713  
Expression ‘PaAlsaStream\_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )’ failed in ‘src/hostapi/alsa/pa\_linux\_alsa.c’, line: 2837  
Exception in thread Thread-14:  
Traceback (most recent call last):  
File “/usr/lib64/python3.9/threading.py”, line 973, in \_bootstrap\_inner  
self.run()  
File “/home/iamsure/mycroft-core/mycroft/client/speech/listener.py”, line 79, in run  
with self.mic as source:  
File “/home/iamsure/mycroft-core/mycroft/client/speech/mic.py”, line 140, in **enter**  
return self.\_start()  
File “/home/iamsure/mycroft-core/mycroft/client/speech/mic.py”, line 147, in \_start  
self.stream = MutableStream(self.audio.open(  
File “/home/iamsure/mycroft-core/.venv/lib64/python3.9/site-packages/pyaudio.py”, line 750, in open  
stream = Stream(self, \*args, \*\*kwargs)  
File “/home/iamsure/mycroft-core/.venv/lib64/python3.9/site-packages/pyaudio.py”, line 441, in **init**  
self.\_stream = pa.open(\*\*arguments)  
OSError: [Errno -9997] Invalid sample rate

---

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 3, 2021, 11:16pm UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/2 "2021-10-03T23:16:45Z")

</div>

I should note that mycroft-cli-client shows _no_ mic level at the bottom right, despite recording and playback working without issue in the test.

---

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 12, 2021, 10:37pm UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/3 "2021-10-12T22:37:55Z")

</div>

Bumpity bump bump bump

---

<div class="post-metadata">

### Author: ![mike99mac](https://community.openconversational.ai/user_avatar/community.openconversational.ai/mike99mac/32/2016_2.png) [@mike99mac](https://community.openconversational.ai/u/mike99mac)
#### Post date: [October 12, 2021, 11:34pm UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/4 "2021-10-12T23:34:05Z")

</div>

I’ve seen this before. I believe it was fixed after adding the environment variable XDG\_RUNTIME\_DIR to the systemd config file that starts Mycroft (shown below). It assumes the uid Mycroft is running as is 500 (pi). It allows Mycroft to find the socket to talk to the message bus. I may be wrong, but it might be worth a try.

```auto
$ sudo vi mycroft.service
[Unit]
Description=Mycroft AI
After=pulseaudio.service
[Service]
User=pi
WorkingDirectory=/home/pi/
ExecStart=/home/pi/mycroft-core/bin/mycroft-start all
ExecStop=/home/pi/mycroft-core/bin/mycroft-stop
Type=forking
Restart=no
Environment="XDG_RUNTIME_DIR=/run/user/500"
[Install]
WantedBy=multi-user.target

```

Hope this helps.

```
-Mike M
```

---

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 13, 2021, 12:09am UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/5 "2021-10-13T00:09:35Z")

</div>

Sadly that wasn’t it. I didn’t have a service file yet, and even created it and modified the paths to match and it didn’t start mycroft.

I tried manually exporting the XDG\_RUNTIME\_DIR and starting mycroft manually and it’s the same result: Error -9997 Invalid sample rate and no Mic level showing.

---

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 13, 2021, 12:23am UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/6 "2021-10-13T00:23:27Z")

</div>

I stand corrected! That did change something. Now that I matched the userid to mine, pulse was (I think?) able to connect, but pulseaudio still dies with the sample rate and mic level is still blank. ☹

Establishing Mycroft Messagebus connection…  
Connected to Messagebus!  
ALSA lib pcm.c:2660:(snd\_pcm\_open\_noupdate) Unknown PCM cards.pcm.rear  
ALSA lib pcm.c:2660:(snd\_pcm\_open\_noupdate) Unknown PCM cards.pcm.center\_lfe  
ALSA lib pcm.c:2660:(snd\_pcm\_open\_noupdate) Unknown PCM cards.pcm.side  
ALSA lib pcm\_route.c:877:(find\_matching\_chmap) Found no matching channel map  
ALSA lib pcm\_route.c:877:(find\_matching\_chmap) Found no matching channel map  
ALSA lib pcm\_route.c:877:(find\_matching\_chmap) Found no matching channel map  
ALSA lib pcm\_route.c:877:(find\_matching\_chmap) Found no matching channel map  
Cannot connect to server socket err = No such file or directory  
Cannot connect to server request channel  
jack server is not running or cannot be started  
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock  
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock  
20:21:00.025 | INFO | 135161 | mycroft.client.speech.listener:create\_wake\_word\_recognizer:328 | Creating wake word engine  
20:21:00.026 | INFO | 135161 | mycroft.client.speech.listener:create\_wake\_word\_recognizer:351 | Using hotword entry for hey mycroft  
20:21:00.027 | INFO | 135161 | mycroft.client.speech.hotword\_factory:load\_module:500 | Loading “hey mycroft” wake word via precise  
20:21:01.654 | INFO | 135161 | mycroft.client.speech.listener:create\_wakeup\_recognizer:365 | creating stand up word engine  
20:21:01.654 | INFO | 135161 | mycroft.client.speech.hotword\_factory:load\_module:500 | Loading “wake up” wake word via pocketsphinx  
20:21:01.757 | INFO | 135161 | **main** :on\_ready:179 | Speech client is ready.  
Expression ‘paInvalidSampleRate’ failed in ‘src/hostapi/alsa/pa\_linux\_alsa.c’, line: 2043  
Expression ‘PaAlsaStreamComponent\_InitialConfigure( &self-\>capture, inParams, self-\>primeBuffers, hwParamsCapture, &realSr )’ failed in ‘src/hostapi/alsa/pa\_linux\_alsa.c’, line: 2713  
Expression ‘PaAlsaStream\_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )’ failed in ‘src/hostapi/alsa/pa\_linux\_alsa.c’, line: 2837  
Exception in thread Thread-8:

---

<div class="post-metadata">

### Author: ![mike99mac](https://community.openconversational.ai/user_avatar/community.openconversational.ai/mike99mac/32/2016_2.png) [@mike99mac](https://community.openconversational.ai/u/mike99mac)
#### Post date: [October 13, 2021, 12:43am UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/7 "2021-10-13T00:43:56Z")

</div>

@thekabal - glad it helped somewhat.

I have an early draft of a doc describing an install of a entire music playing stack (and some details of the boombox hardware). Maybe that will clear up further errors.

However, I can’t seem to upload a PDF to Google drive without it borking the content. Anyone can send a request to [mike99mac@gmail.com](mailto:mike99mac@gmail.com) and I’ll send back the PDF. Feedback will be appreciated.

```
-Mike M
```

---

<div class="post-metadata">

### Author: ![SGee](https://community.openconversational.ai/user_avatar/community.openconversational.ai/sgee/32/3411_2.png) [@SGee](https://community.openconversational.ai/u/SGee)
#### Post date: [October 13, 2021, 10:41am UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/8 "2021-10-13T10:41:25Z")

</div>

python 3.9 and the pyaudio/portaudio packages are the problems in this case. Apart from that, i wouldn’t suggest using 3.9 at this point in time since you will likely running into more issues.

---

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 13, 2021, 11:36am UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/9 "2021-10-13T11:36:42Z")

</div>

SGee\> Which version of Python and pyaudio/portaudio packages are supported/primarily used by Mycroft?

---

<div class="post-metadata">

### Author: ![SGee](https://community.openconversational.ai/user_avatar/community.openconversational.ai/sgee/32/3411_2.png) [@SGee](https://community.openconversational.ai/u/SGee)
#### Post date: [October 13, 2021, 11:49am UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/10 "2021-10-13T11:49:58Z")

</div>

3.7 is the version of choice. Py 3.8 also works without hickups.

I’ve monitored ` **arguments` not long ago (with 3.9), but i can’t remember what i’ve found. If you want to know whats happening just log those arguments and look around in pyaudio (pretty uncomplicated lib) why it cant work with the sample rate argument.

---

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 13, 2021, 12:34pm UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/11 "2021-10-13T12:34:33Z")

</div>

After installing pyenv, setting the _global_ version to 3.8.12, logging out and back in, and running mycroft - IT WORKS.

**Solved!**

Many, many thanks to @SGee for the solution.

---

<div class="post-metadata">

### Author: ![SGee](https://community.openconversational.ai/user_avatar/community.openconversational.ai/sgee/32/3411_2.png) [@SGee](https://community.openconversational.ai/u/SGee)
#### Post date: [October 30, 2021, 11:12am UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/12 "2021-10-30T11:12:03Z")

</div>

Just realized that i assumed - appearently rightfully so- you’re running on ARM from the get go.  
python 3.9 (and base mycroft-core) works on x64.  
(just to not rule out py3.9 categorically)

---

<div class="post-metadata">

### Author: ![thekabal](https://community.openconversational.ai/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thekabal](https://community.openconversational.ai/u/thekabal)
#### Post date: [October 30, 2021, 9:01pm UTC](https://community.openconversational.ai/t/cannot-launch-errno-9997-invalid-sample-rate/11331/13 "2021-10-30T21:01:52Z")

</div>

Kernel Information: Linux 5.14.9-200.fc34.x86\_64 x86\_64 (64 bit)  
OS Version: Fedora 34 (Server Edition)

It’s not on a Rpi, it’s a full Linux x86\_64 machine.
