i wrote a quick and dirty (just for fun) example to implement a recorder starting to record, when it detects some sound and keeps recording while not idle for 2 seconds - saving the result to test.wav. i know the range of an audio value is signed so the max(…) is not nice here, but it works quite well. the check againts 2000 is totally random chosen.
the script uses pyalsaaudio and needs the matrixio-malos serivce running.
Thanks! The examples are working!
Also spectrum.py after changing to the rigth device.
I’m happy to test the Matrix Voice now.
btw: matrixio-malos serivce was running but I had to start micarray_alsa_pipes.py to get it working…
I ran into the same issue, I try your code and I got this error :
indent preformatted text by 4 spaces
Traceback (most recent call last):
File “voice.py”, line 8, in
mic = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL, device=‘mic_channel8’)
TypeError: ‘device’ is an invalid keyword argument for this function
So I wonder if you can share your /etc/asound.conf file and if exist your ~/.asound.conf
no you only need to start the matrixio-malos.service it should create the pipes in the /tmp folder.
# malos service is needed:
sudo apt install matrixio-malos
# service should be started by default, but to be sure:
sudo systemctl start matrixio-malos.service
# check if the pipes are created
as alternative you can create those pipes by running the cpp programm an let it keep running. with the installation of the malos.serivce, the alsa sound config should be set up properly. so no need define your own ~/.asound.conf
is this happening before, or while recording, i could reproduce it one. it seems that the unpack format get’s generated wrong. eventually is the length value not a regular, or negative number, will test further.