# MicroPi not running properly

**URL:** https://discourse.nodered.org/t/micropi-not-running-properly/37408
**Category:** General
**Created:** [12 December 2020 16:51 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408 "2020-12-12T16:51:29Z")
**Posts on this page:** 14
**Page:** 2

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [16 December 2020 09:37 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/21 "2020-12-16T09:37:24Z")

</div>

> [@kart-able](#):
>
> With the same configuration, if I boot with Rhasspy and add the system wide daemon, I get `sox FAIL formats: can't open input 'alsa_input.usb-OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1-01.multichannel-input': can not open audio device: No such entity`

This all sounds like Rhasspy is not using pulseaudio to record from. As soon as Rhasspy accesses the microphone with alsa it will become unavailable to pulseaudio and pulseaudio will act like it doesn’t exist anymore. You won’t see it in pactl list and you can’t access it with any other program as long as Rhasspy is blocking it.

> [@kart-able](#):
>
> sox-record is then frozen

I think this is the same happening in reverse kind of. Sox is recoding from the pulseaudio sound server and as soon as Rhasspy starts it tries to access the device on the alsa level killing the device for pulseaudio.

It’s gonna have to be either all pulse or non.

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [16 December 2020 09:49 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/22 "2020-12-16T09:49:54Z")

</div>

Ok scrap all the pulseaudio and are you willing to try something?  
I forgot all about dsnoop and dmix for alsa:

> **[Alsa Opensrc Org - Independent ALSA and linux audio support site](https://alsa.opensrc.org/Dsnoop)**

Can you change your `asound.conf` to something like:

```auto
pcm.!default {
    type asym
    playback.pcm "speaker"
    capture.pcm "array"
}

pcm.speaker {
    type plug
    slave.pcm "hw:ALSA"
}

pcm.array {
    type dsnoop
    ipc_key 666666
    slave {
        pcm "hw:CameraB409241"
        channels 2
    }
}

```

This should allow you to record from the same alsa device with both sox and Rhasspy directly. No pulseaudio needed.  
You can just use the default device from both Rhasspy and sox / nodered.  
Also **clear** your asoundrc so it doesn’t interfere with the asound.conf.

---

<div class="post-metadata">

### Author: ![kart-able](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kart-able/32/33133_2.png) [@kart-able](https://discourse.nodered.org/u/kart-able)
#### Post date: [16 December 2020 11:57 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/23 "2020-12-16T11:57:26Z")

</div>

> [@JGKK](#):
>
> This all sounds like Rhasspy is not using pulseaudio to record from.

I had also tested with a asound.conf as suggested in the rhasspy documentation

```auto
pcm.!default {
    type pulse
    # If defaults.namehint.showall is set to off in alsa.conf, then this is
    # necessary to make this pcm show up in the list returned by
    # snd_device_name_hint or aplay -L
    hint.description "Default Audio Device"
}
ctl.!default {
    type pulse
}

```

and checked if my microphone is still there with `pactl list` even with rhasspy running.

The result is  
`sox FAIL formats: can't open input 'alsa_input.usb-OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1-01.multichannel-input': can not open audio device: No such entity`  
So what?

Ok lets forget pulseaudio!

---

<div class="post-metadata">

### Author: ![kart-able](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kart-able/32/33133_2.png) [@kart-able](https://discourse.nodered.org/u/kart-able)
#### Post date: [16 December 2020 12:09 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/24 "2020-12-16T12:09:31Z")

</div>

Ok then I changed asound.conf as you said, but...

Even with a `sudo pulseaudio -D --system` after booting, I have  
`sox FAIL formats: can't open input 'alsa_input.usb-OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1-01.multichannel-input': can not open audio device: No such entity`

`pactl list` says the device is there!

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [16 December 2020 12:27 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/25 "2020-12-16T12:27:11Z")

</div>

> [@kart-able](#):
>
> Ok lets forget pulseaudio!

Did you change the asound.conf to the dsnoop one i posted?  
Than just use:  
**-t alsa default** in the sox record node and default device in Rhasspy.  
That should work hopefully.

---

<div class="post-metadata">

### Author: ![kart-able](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kart-able/32/33133_2.png) [@kart-able](https://discourse.nodered.org/u/kart-able)
#### Post date: [16 December 2020 15:46 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/26 "2020-12-16T15:46:02Z")

</div>

It is recording but I can't hear anything. Of course I checked audio output for analog, as I am using a headphone.

Rhasspy is running and it works as usual.

We are close to the solution 😉

PS: I have set to **-t alsa default** in sox-record, but not in Rhasspy. For this, I should check with all the settings that allow it (only audio recording and audio playing apparently, but not for the wake word...)

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [16 December 2020 16:16 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/27 "2020-12-16T16:16:27Z")

</div>

Have you tried an asound conf like this?

```auto
pcm.!default {
    type asym
    playback.pcm "speaker"
    capture.pcm "array"
}

pcm.speaker {
    type dmix
    ipc_key 555555
    slave {
        pcm "hw:Headphones"
    }
}

pcm.array {
    type dsnoop
    ipc_key 666666
    slave {
        pcm "hw:CameraB409241"
        channels 2
    }
}

```

This would create a dmix pcm for the headphones which both Rhasspy and Nodered can use. This would be the system default than.  
Dmix is the output equivalent to the dsnoop input.

---

<div class="post-metadata">

### Author: ![kart-able](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kart-able/32/33133_2.png) [@kart-able](https://discourse.nodered.org/u/kart-able)
#### Post date: [16 December 2020 16:33 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/28 "2020-12-16T16:33:25Z")

</div>

Same problem.  
I never used dmix and dsnoop.  
And I don't know what the ipc\_key stand for.

NB: Checking my .asoundrc file, I see that the system insists adding lines

```auto
pcm.output {
	type hw
	card 1
}

ctl.!default {
	type hw
	card 1
}

```

probably because I checked **Analog** in the settings on the screen's top right corner

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [16 December 2020 17:28 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/29 "2020-12-16T17:28:38Z")

</div>

Ok no need for dmix, it’s build in by default for the headphone output.  
Did you read the link I posted above? It explains it. Dmix/Dsnoop are alsa plug-ins that enable the down mix of multiple streams to one sound device.  
So working for me is this asound.conf:

```auto
pcm.!default {
    type asym
    playback.pcm "speaker"
    capture.pcm "array"
}

pcm.speaker {
    type plug
    slave.pcm "hw:Headphones"
}

pcm.array {
    type dsnoop
    ipc_key 666666
    slave {
        pcm "hw:CameraB409241"
        channels 2
    }
}

```

I verified that this works on two pi’s. But those are both headless minimal installations as I don’t actually have any Linux machine here running a desktop. There all headless unfortunately.  
I just also pushed an update to the sox nodes to github. So if you update the nodes from your nodered directory with `npm update johanneskropf/node-red-contrib-sox-utils` you will be able to now also choose the define manual output device option in the play node.  
So to make sure something plays to the headphones you can use something like `-t alsa hw:Headphones` if that’s the name of the headphones in `aplay -l` to play directly to them or you use `-t alsa speaker` to use the pcm defined above in the asound.conf.

> [@kart-able](#):
>
> probably because I checked **Analog** in the settings on the screen's top right corner

No clue as I said I run minimal headless. What is card 1 if you do aplay -l? Im sorry won’t be able to help with that much but using the manual output device input I added to the play node should work around that.

Edit and Ps:  
Verify that the hw name is Headphones in **aplay -l** , this is my output:

```auto
pi@testipi:~/.node-red $ aplay -l
****List of PLAYBACK Hardware Devices****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 7/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: ArrayUAC10 [ReSpeaker 4 Mic Array (UAC1.0)], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

```

So the name to use in either the asound.conf or the manual device input will be the one straight behind _card 1:_ or _card 2:_ etc.

Edit 2:  
Did you confirm that it actually recorded anything by using something like FileZilla to transfer the recorded file over to another computer and play it there?

---

<div class="post-metadata">

### Author: ![kart-able](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kart-able/32/33133_2.png) [@kart-able](https://discourse.nodered.org/u/kart-able)
#### Post date: [17 December 2020 07:16 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/30 "2020-12-17T07:16:42Z")

</div>

> [@JGKK](#):
>
> use `-t alsa speaker` to use the pcm defined above in the asound.conf

You mean `-t alsa array`. I tried that in the node and it gave an error 'busy'. So that I stopped rhasspy and it works!

> [@JGKK](#):
>
> Did you read the link I posted above?

Yes I read the documentation but I miss the basic to understand most of it. It's not like the docs of Rhasspy which I can work on.

Now we have it. The solution for having sox-record and Rhasspy side by side is to have both using dsnoop. I'll work on it.

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [17 December 2020 10:30 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/31 "2020-12-17T10:30:51Z")

</div>

Ok I just did. further testing and the asound.conf needed some more tuning. I also read a little bit in the Rhasspy docs for you.  
What should work:

- use the following **asound.conf** :

```auto
defaults.pcm.rate_converter "samplerate"

pcm.!default {
    type asym
    playback.pcm "speaker"
    capture.pcm "array"
}

pcm.speaker {
    type plug
    slave.pcm "hw:Headphones"
}

pcm.array {
    type plug
    slave.pcm "dsnooparray"
}

pcm.dsnooparray {
    type dsnoop
    ipc_key 666666
    slave {
        pcm "hw:CameraB409241"
        channels 2
    }
}

```

- in nodered in the sox record node record using manual source input with:

```auto
-t alsa array

```

- in Rhasspy use the ALSA recording option that starts a local arecord command configured like this in your profile:

```auto
"microphone": {
  "system": "arecord",
  "arecord": {
    "device": "array"
  }
}

```

- This should lead Rhasspy to use an **arecord** command as follows as its audio input:

```auto
arecord -D array -t raw -r 16000 -f S16_LE -c 1

```

which I just tested. I can record with the above **arecord** command from the commandline while simultaneously also recording with sox in nodered from the same device.  
I tested by recording/streaming continuously with the sox record node in nodered and than running `arecord -D array -t raw -r 16000 -f S16_LE -c 1 | sox -t raw -L -e signed-integer -c 1 -r 16000 -b 16 - btest.wav trim 0 10` on the commandline. This is nothing more than running the same command Rhasspy would run and piping it via sox into a wav file so that I could confirm it’s working.  
As this works no problem I see no reason why it shouldn’t work with Rhasspy using the same command effectively.

Johannes

---

<div class="post-metadata">

### Author: ![kart-able](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kart-able/32/33133_2.png) [@kart-able](https://discourse.nodered.org/u/kart-able)
#### Post date: [17 December 2020 18:52 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/32 "2020-12-17T18:52:25Z")

</div>

Johannes, thank you for your time.  
But with these settings, I have no wake word (snowboy) and no intent recognition (fsticuffs), at least for the audio part.

I have also tested again with pulse. As you can see, there are several options offered with arecord...

 ![2020-12-17-193858_1280x1024_scrot](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c851b07e6170c7d4a5c75c330cda23a0cff717d1.png)

At this point in time, I should probably look for help in the Rhasspy forum. What do you think?

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [17 December 2020 18:58 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/33 "2020-12-17T18:58:04Z")

</div>

With the asound.conf as above choosing arecord and the simple just default option should work. Or you look at the section for using a custom record command. There you could use sox or arecord as above.  
For the question whether snowboy uses pyaudio no matter what you are better of over at the Rhasspy forum.  
You can find me on the Rhasspy forum too, same user name.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [31 December 2020 18:58 UTC](https://discourse.nodered.org/t/micropi-not-running-properly/37408/34 "2020-12-31T18:58:12Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/micropi-not-running-properly/37408.md?page=1)
