I am trying to have MicroPi work, but I can't. Why is that? Is there something specific I must undestand before?
I have tried with the MicroPi Microphone Wav-Filewriter [Demo Flow] and of course installed the MicroPi nodes. I have indicated a path with a file name. Just wandering why it does not ask which microphone I am using.
There is a response underneath the node which indicates it is recording. But I get nothing in the debug pane and no created file.
It looks like node-red-contrib-micropi hasn't been update in 4 years. You might want to explore the FLOWS tab here on th e forum and see if there is another microphone node that will work for you.
You might try out node-red-contrib-sox-utils which is in beta but I have gotten it to work with my usb mic on a Mac and a Pi
@JGKK I am testing Sox utils but it seems it does not find my device plughw:CameraB409241
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM input
sox FAIL formats: can't open input `default': snd_pcm_open error: No such file or directory
Did you use the dropdown to choose your device or the manual input for device choice? Doesn’t it show the card as a selection in the dropdown?
Or did you try the default option because that sometimes will only work if you actually configured a default for recording.
If you want to use the manual input option here is what you need to do as its not in the readme yet. It has to be in the format of the sox commandline argument for choosing a device.
You can go/ssh to your commandline and use arecord -l which will give you an output like this:
pi@testipi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: ArrayUAC10 [ReSpeaker 4 Mic Array (UAC1.0)], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
This will be similar for your attached mic (playstation eye?). What this tells you is its sound device 1 and subdevice 0 you want to use. Of course those numbers can differ.
This translates to:
-t alsa hw:1,0
as an input for the manual device input field in the node.
But if you can see the mic with arecord -l this shouldn’t be necessary as the device should be shown in the nodes source dropdown.
Just got one of the old ps eye cams out of the box in Storage and updated a nodered to the latest sox-utils node.
Here is what I see when I do arecord -l just after I plugged in the ps eyecam:
Can you post some screenshots of what the node shows for you and what you arecord -l output is?
Johannes
Edit and PS
I just checked and the error is similar to what I get when I define a default in the asound.conf and don’t actually have that device connected or when there is no default defined at all which is the case for recording devices if you didn’t define one in the asound.conf as the raspberrypi and most other Linux soc s don’t have an inbuilt audio input. So I think it’s one of those two but you should just be able to choose it from the dropdown or use the method above to enter it manually if on any Linux which uses alsa.
You could also define the mic as default in your /etc/asound.conf file. (You need to edit it with sudo) and once defined there use the default option (dont do this if your running pulseaudio and always make a backup copy of the previous asound.conf file before you change it):
pcm.!default {
type asym
playback.pcm "speaker"
capture.pcm "array"
}
pcm.speaker {
type plug
slave.pcm "hw:ALSA"
}
pcm.array {
type plug
slave.pcm "hw:CameraB409241"
}
Hmm I think I know why the dropdown doesn’t work. I use a regex to generate the entries for the dropdown from the systems list. I think this fails with any system language other than English unfortunately. As for the resource busy, this only happens when the resource is used / blocked by something else. just as a Note I’m not quite sure about the syntax in your asoundrc either. I would define it as above in my example as using card Numbers instead of names there can lead to many errors as cards can change their order on a reboot.
Are you sure Rhasspy or any other possible programs released the sound resources? If you do a simple arecord command from the command line is it busy too?
I would do a reboot just in case. Unplug the PlayStation Eye before rebooting as it can block a boot on the pi.
I'm stupid. I erased a flow connected to Rhasspy, but Rhasspy was still running in docker... Actually it all works!
Now I suppose there is no possibility to have both running using the same microphone?
What I'd like to do is take a quick recorded message after a specific intent in Rhasspy. But this is more a topic for Rhasspy...
An http request in the form http://localhost:12101/api/stop-recording would probably do it, but the recording with sox-record starts too soon.
Yes that is possible. You will have to use a soundserver that sits on top of alsa.
Do you have pulseaudio installed? I think it comes standard with the Desktop version of Raspberrypi OS but if you use the light headless version like me you have to install it.
So first do a
pulseaudio --version
Which should give you something like:
pulseaudio 12.2
Otherwise install it using:
sudo apt-get install pulseaudio pulseaudio-utils
If it’s installed.
Second check if it’s running already using top or htop.
If it’s running you need to kill it as you need to start it in systemwide mode using:
sudo pulseaudio -D --system
than add the user running nodered to the pulseaudio and pulseaudio-access groups, for example:
sudo adduser pi pulse
sudo adduser pi pulse-access
Now install the handler for pulse audio in sox
sudo apt-get install libsox-fmt-pulse
Now you can use:
-t pulseaudio default
as the manual source for recording from nodered. And as pulseaudio sinks are non blocking you could also use a sox record command as your record command in Rhasspy pointing to the same sink.
But be warned pulseaudio can be fiddly especially running in systemwide mode and you would need to add system d script to start it automatically when you boot.
Yes as pulseaudio sinks are non blocking. But it will only work with nodered if the user running nodered is part of the pulse groups and pulse audio is running in systemwide mode.
You can than use the command:
pactl list
to get all devices. This will get you a very long list. If you look for the Source headers in that list you can find the name of individual source devices and use those in the manual input source in the node like for example:
as a custom record command which is pretty similar to what the sox node uses in the background. You could also use the pulseaudio native parec command of course but you would have to look up the syntax for that yourself as i have never used it.
I really don’t know. I don’t use rhasspy myself as i use voice2json. I only have a passing similarity with the hermes protocol as i used to use snips.
Shouldn’t pyaudio also work with pulseaudio?
You probably need system wide mode and correct group membership too but it should work.
After all this, I will have a look at voice2json which is given to work well in combination with nodered.
I followed your instructions for pulseaudio and I tried -t pulseaudio default. Recording starts but the flow is nill. I have lots of In:0.00% 00:00:00.00 [00:00:00.00] Out:0 [ | ] Clip:0
I checked for the input device with pactl list as you suggested, but I can't find my microphone.
One other thing: the settings in the sox-record node are ignored in the output
Thats just the input settings, its the native format of the source your using. This gets converted to the format from the nodes settings. When you play a recorded wav you will see it has the settings from the node. This can be confusing but thats just how linux audio is.
Can you copy the output to a txt file and send to me as a pm?
I really recommend to use the global /etc/asound.conf as per my example above in this case as the user specific asoundrc can cause trouble as its not necessarily picked up by sox running from nodered or pulseaudio which is running under its own user.
Please do, Im the main developer of the nodered nodes for Voice2json and im always happy about feedback and bug reports.
Johannes
Edit
One more thing when you did the pactl list command where you running Rhasspy or Nodered recording from the mic with alsa at the same time?
Because devices in use from the lower level of alsa at the time will not show up in the pulseaudio source list as alsa is blocking them when in use.
That was it for one thing. I stopped Rhasspy and I could get the expected result.
So that I tried with -t pulseaudio alsa_input.usb-OmniVision_Technologies__Inc._USB_Camera-B4.09.24.1-01.multichannel-input in the node.
But recording won't start 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: Connection refused
even after I added an asound.conf file in /etc
pcm.!default {
type pulse
playback.pcm "speaker"
capture.pcm "array"
}
pcm.speaker {
type plug
slave.pcm "hw:ALSA"
}
pcm.array {
type plug
slave.pcm "hw:CameraB409241"
}
Are you sure your running pulseaudio as systemwide daemon and that the user running nodered is part of the pulse and the pulse-access group?
I just plugged the ps eye into a test pi. I did not change anything in the asound.conf or asoundrc file so its not system default its just plugged in.
I did pactl list and got this:
Im even using voice2json right now streaming from the Playstation eye with the sox record node to the wake word node and this works no problem.
As its pulse I just tested and I can record from it with another record node at the same time no problem.
And as I said the Playstation Eye is not in my asound.conf I just plugged it in and went straight to nodered.
Edit:
Also making sure when you tried recording from nodered you hadn’t started Rhasspy back up or you were using pulseaudio as a source from Rhasspy.
You are right, I must check that on each boot. Now it works, but only without Rhasspy running in docker.
I have made several tests and one of them leads to freezing sox-record, with these steps:
booting without rhasspy
checking for the microphone with pactl list and the system wide daemon with sudo pulseaudio -D --system (user pi is always ok)
pcm.!default {
type pulse
playback.pcm "speaker"
capture.pcm "array"
}
pcm.speaker {
type plug
slave.pcm "hw:ALSA"
}
pcm.array {
type plug
slave.pcm "hw:CameraB409241"
}
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