Use speaker connection from Matrix Voice whis Snips

Hallo,
how can I use the onboard audio amplifer whis snips?

Many thanks for the help!

Matrix Voice attached to Pi?

Yes, I use Matrix Voice on Pi

Can someone please tell me how to get the voice output from snips to the speaker terminals of the matrix voice board? The Matrix Voice board is on a Raspberry Pi 3 and runs with stretch.
Thank you!

Hi @kmbach,

Setting the MATRIX Voice audio outputs as the default speaker should address this issue. Check out my response to your other post to try this out.

Best,
Samreen

Many thanks for the answer.

With
pcm.speaker {
type plug
slave {
pcm “hw:0,0”
rate 16000
}
}
the sound works on the Raspi. Snips works.

With
pcm.speaker {
type plug
slave {
pcm “hw:0,0”
}
rate 16000
}
the sound does not work on the Raspi.

With
pcm.speaker {
type plug
slave {
pcm “hw:2,1”
rate 44100
}
}
the Raspi crashed when saying hotword in snips.

With
pcm.speaker {
type plug
slave {
pcm “hw:2,1”
}
rate 44100
}
the sound does not work, the Raspi not crashed.

I disable snips und test:
systemctl stop snips-audio-server
amixer set PCM 100% && arecord recording.wav -f S16_LE -r 16000 -d 5
Simple mixer control ‘PCM’,0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback -10239 - 400
Mono: Playback 400 [100%] [4.00dB] [on]
Aufnahme: WAVE ‘recording.wav’ : Signed 16 bit Little Endian, Rate: 16000 Hz, mono
Wiedergabe: WAVE ‘recording.wav’ : Signed 16 bit Little Endian, Rate: 16000 Hz, mono

root@raspi_snips:~$ aplay recording.wav
ALSA lib pcm_plug.c:1263:(_snd_pcm_plug_open) Unknown field rate
aplay: main:788: Fehler beim Öffnen des Gerätes: Das Argument ist ungültig #(Error opening device: The argument is invalid)

Whis
pcm.speaker {
type plug
slave {
pcm “hw:2,1”
}
}
root@raspi_snips:~$ aplay recording.wav
Wiedergabe: WAVE ‘recording.wav’ : Signed 16 bit Little Endian, Rate: 16000 Hz, mono
aplay: set_params:1363: Fehler beim Setzen der Hardware-Parameter:
ACCESS: RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
RATE: 16000
PERIOD_TIME: 125000
PERIOD_SIZE: 2000
PERIOD_BYTES: 4000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 8000
BUFFER_BYTES: 16000
TICK_TIME: 0

Raspberry Pi 3
Raspbian stretch
Kernel 4.19.42-v7+ #1219
matrixio-kernel-modules Version 0.1.8
Installing Snips Led Control v1.9.8

Many thanks for the support.

Hi,
I had reported that it still is not possible and what I have tried.
I would have been happy about an answer.
What else is the forum for?

Greetings Klaus

Hello @kmbach,

Apologies for the delay in response.

Yes, the rate ... part has to be right below the pcm "hw.." line, I have corrected that in my first post.

Regarding the audio output for Snips not working through the MATRIX Voice speaker outputs, I found that it is actually more complicated than just forcing the playback to be sampled at 44100 Hz. The audio being played has to be 44100 Hz sampled audio in the first place. That’s why it works for 16000 Hz since that is likely what the Snips playback audio is sampled at.

You received errors with arecord as well since you were recording at 16000 Hz sampling rate while playback was being forced for 44100 Hz sampled audio.

I’m not sure if there’s a straightforward solution to this. My next idea is to try converting the Snips audio to 44100 Hz sampled audio before playback. Again, I haven’t tried it yet. I will give it a go and follow-up within the week.

There are some tools to do this using sox in the command line for recordings. Maybe it is possible with Snips audio as well.

Best,
Samreen

Hello Samreen,

do you already have new insights? I am still interested in a solution.
Thank you very much!

Best, kmbach

Hi @kmbach,

I have not been able to try this yet. I will let you know as soon as I make some progress!

Best,
Samreen

Hello i have same problem and i put a post on snips community

@nicoxygen,

Welcome to the community!

Try the fix here. It is a combination of adding rate 16000 to your pcm.speaker section in /etc/asound.conf and placing portaudio_playback = "default" in /etc/snips.toml file. Your playback hw device will be 2,1, matching your aplay -l output.

Let me know how it goes!

Best,
Samreen

with rate 16000 on asound.conf + hw:2,1 for speaker because card is on 2 + device on 1
+
portaudio_playback = “default” on snips.toml
when i says " hey snips"
i have a brief sound on mic and raspbian crash and I have to manually restart the raspberry

@nicoxygen,

I didn’t realize your speakers are connected to the MATRIX Voice audio jack and not the Raspberry Pi audio jack.

We have not yet figured out how to output Snips audio through the MATRIX Voice audio jack when it is fitted onto the Raspberry Pi. There is an audio streamer project that a community member came out with using an ESP32 MATRIX Voice in which the MATRIX Voice audio jack can output audio but it is programmatically written via SPI to the MATRIX Voice’s amplifier.

This is something that we still need to look into. We know the general cause of the issue. I read that the playback audio for Snips mirrors the audio capture characteristics which by default is 16000 Hz mono for the MATRIX Voice. The way the MATRIX Voice audio is jack is configured at the moment, it can only output audio at 44100 Hz stereo. So, that is where the issue arises.

If you try the fix from the post above, but replace the hw numbers to the Raspberry Pi audio jack and connect the speakers to that, it should work.

Best,
Samreen

with hw:2,1 and speaker connected on left and right, sam test speaker work perfectly but not
after " hey snips"

@nicoxygen,

I think I figured it out. Try the following /etc/asound.conf to get Snips audio output from the MATRIX Voice’s audio jack.

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

pcm.mic {
   type softvol
   slave {
     pcm "array"
   }
   control {
     name "MicArray Master"
        card "MATRIXIOSOUND"
   }
}

pcm.speaker {
  type plug
  slave {
    pcm "plughw:2,1"
    rate 44100
  }
}

pcm.array {
  type plug
  slave {
    pcm "hw:MATRIXIOSOUND"
  }
}

No changes required in /etc/snips.toml.

@kmbach,

It’s been a while since you asked me for help with this and I think this is it! Please try as well.

Since you are using the speaker terminals instead of the headphone jack, you should change the default MATRIX Voice output to Speaker. You should be able to do this by typing the following in your terminal first.

amixer -c 2 set Master_Playback_Switch Speaker

Oddly enough, the only difference from what I had suggested long ago was having plughw instead of hw.

Let me know how it goes!

Best,
Samreen

1 Like

thanks it work perfect

1 Like

Unfortunately, this attitude does not lead to success for me.
The raspberry crashes while detecting the hotword.
I have to restart it manually.

Best regards
kmbach

@kmbach,

What is the error log for sam watch from your PC and journalctl -f -u snips-audio-server from the Raspberry Pi when you say the hotword?

Best,
Samreen

:root@raspi_snips:~$ journalctl -f -u snips-audio-server
– Logs begin at Fri 2019-10-18 13:17:01 CEST. –
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.surround41
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.surround50
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.surround51
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.surround71
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.iec958
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.hdmi
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.modem
Okt 18 16:42:30 raspi_snips snips-audio-server[890]: ALSA lib pcm.c:2495:(snd_pc m_open_noupdate) Unknown PCM cards.pcm.phoneline
Okt 18 16:42:31 raspi_snips snips-audio-server[890]: INFO:snips_audio_portaudio : Use input device: “MATRIXIO-SOUND: - (hw:2,0)”
Okt 18 16:42:31 raspi_snips snips-audio-server[890]: INFO:snips_broadcast_mqtt_s erver: Starting broadcasting audio on hermes for site “default”