Use speaker connection from Matrix Voice whis Snips

@kmbach,

Does it crash after that? It doesn’t seem to be showing the reason for the crash, but if it’s at that point, it still has to do with audio output.

Have you updated to the latest version of Snips? The update may help. You can do so with the directions here.

Best,
Samreen

I have the system update:

Fehler traten auf beim Bearbeiten von:
/tmp/apt-dpkg-install-DLqCBy/19-matrixio-kernel-modules_0.1.9_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
[mmcblk0p2]:root@raspi_snips:~$

The system is does not boot anymore.

I have to get the system up and running again.

Best kmbach

@kmbach,

You could try from scratch and then implement the /etc/asound.conf above, or you could purge and reinstall the matrixio-kernel-modules package.

Purge with

sudo apt purge matrixio-kernel-modules

Re-install with

sudo apt install matrixio-kernel-modules

Best,
Samreen

I had to redo the entire system now. But with success! Playback
now works through the MATRIX speaker terminals.

Thank you so much!

Best regards

kmbach
1 Like

Hello Samreen have you tested speaker with rhasspy because I can’t get them to work

asound.conf has

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

amixer -c 2 set Master_Playback_Switch Speaker

but what an output in setting / sound of rhasspy because each time I select an output and save rhasspy does not take it into account.

@nicoxygen,

I will test this and get back to you this week!

Best,
Samreen

Hi @nicoxygen,

I was able to get speaker output from the audio jack of the MATRIX Voice (should also work from the speaker connectors then), with the following.

  • No change to /etc/asound.conf as we will be sending the MATRIXIOSOUND card directly instead of “default”
  • Setting amixer -c 2 set Master_Playback_Switch Headphones in command line (for you would be Speaker if you are plugging into the speaker connectors)
  • Selecting Use aplay directly and hw:CARD=MATRIXIOSOUND,DEV=1: Direct hardware device without any conversions in the Sounds setting as shown below.

My ~/.config/rhasspy/profiles/en/profiles.json looks like below

{
    "microphone": {
        "arecord": {
            "device": "hw:CARD=MATRIXIOSOUND,DEV=0"
        },
        "system": "arecord"
    },
    "sounds": {
        "aplay": {
            "device": "hw:CARD=MATRIXIOSOUND,DEV=1"
        }
    },
    "wake": {
        "system": "porcupine"
    }
}

Make sure to increase the playback volume with:

amixer set PCM 100%

Let me know how it goes!

Best,
Samreen

2 Likes

Hi Samreen,

I am also operating Rhasspy with Matrix Voice. As shown by you I have tried to activate the Matrix speaker output through Rhasspie’s GUI several times. The setting always returned to default device. and thus it never worked. Today I edited the profile.json and got the speakers run.

Now my problem occurs:

I am using some scripts to pass voice messages through Rhasspie’s API (/api/text-to-speech) to my Raspberry that bears Matrix Voice. That worked fine with the Raspberry Jack. Now, with Matrix speaker output, I do not hear the voice messages any more, but Rhasspie’s standard sounds instead (i.e. Wake WAV, Recorded WAV and Error WAV).

Do you have an idea, what needs to be done in this case?

Would it be helpful to address the same issue in the Rhasspy community or would this be confusing? Please advice.

Thanks in advance.

Regards, Thomas

@tobetobe,

No harm also posting on the Rhasspy community.

I assume your scripts are doing something like this to have Rhasspy return voice outputs. Let me test this and get back to you.

Best,
Samreen

Samreen, Thank you for your help.

Yes indeed, my script does something similar. It consists of 3 parts:

  1. setup for mqtt and tts
  2. wakeword identification and voice response
  3. several scripts to trigger different devices, example: temperature with announcement of the requested value

// Script to send Voice via TTS to Rhasspy
// Rhasspy-TTS setup:
let http = require(‘http’);
let options = {
host: ‘192.168.xxx.yyy’, //Rhasspy IP-Adresse
port: 12101, //Rhasspy Port
path: “/api/text-to-speech”,
method: ‘POST’,
headers: {
‘User-Agent’ : ‘ioBroker’,
‘Content-Type’: ‘text/plain’,
// ‘Content-Length’: data.length
}
};

function httpPost(data) {
let req = http.request(options, function(res) {
console.log("http Status: " + res.statusCode);

console.log('HEADERS: ' + JSON.stringify(res.headers), (res.statusCode != 200 ? "warn" : "info"));
});

 // on error
    req.on('error', function(e) { 
    console.log('ERROR: ' + e.message,"warn");
});

 // write data to request body
console.log("Data to request body: " + data);
(data ? req.write(data) : console.log("Daten: keine Daten vorhanden"));
req.end();

}
//______________________________________________________________________________

//Script to respond on WakeWord
const wake = ‘mqtt.0.rhasspy.de.transition.SnowboyWakeListener’ // Datenpunkt aendert sich von listening auf loaded, wenn wakeword erkannt wurde
const befehl = ‘mqtt.0.rhasspy.de.transition.WebrtcvadCommandListener’ // Datenpunkt aendert sich von listening auf loaded, wenn befehl erkannt erkannt wurde
const ansage = ‘Yeah?’ // in case wakeword was recognised
const empf_ok = “OK” // in case command was recognised

on({id: wake, change: “any”},function(obj) {
let empf_code = getState(wake).val ;
if (empf_code== “loaded”){ wakeword(); }
});

on({id: befehl, change: “any”},function(obj) {
let empf_code = getState(befehl).val ;
if (empf_code== “loaded”){ befehl_empf(); }
});

function wakeword(){
httpPost(ansage);
}

function befehl_empf(){
httpPost(empf_ok);
}
//______________________________________________________________________________

//script to ask for temperatures
var intentResult = $(‘mqtt.0.rhasspy.intent.*Temperature’);
var intentArray = [];

for(var i = 0; i < intentResult.length; i++)
{
log(intentResult[i]);
intentArray.push(intentResult[i]);
}

on({id: intentArray, change: “any”}, function (obj) {
log(obj.newState.val);
let intentObject = JSON.parse(obj.newState.val);
if(intentObject.hasOwnProperty(‘device’))
{
var deviceID = intentObject.device;
var state = intentObject.state;
var value = getState(deviceID + state);

    let data = 'It's currently ' + value.val + ' degrees Celsius';
    console.log("data: " + data);
    httpPost(data);
}

});

I’ll be waiting patiently for your answer.

best regards
Thomas

Hey Thomas,

Tried it out and it seems the issue may be with the sampling rate of the text-to-speech WAV files. The MATRIX Voice audio jack is compatible with 44100 Hz 16-bit stereo sound and the WAV files from the TTS is in a different format.

Still trying to find an easy workaround, will keep you posted.

Best,
Samreen

Hey Samreen,

thanks for this information. Maybe it’s a question of the tts system. I am using pico tts currently, since it sounds quite good in German language. However pico tts seems to only support 16 kbps. Mary tts on the contrary allows for ranges from 16 kbps to 48 kbps. Still I haven’t checked whether Mary tts also supports German.

Maybe this way could be an easy workaround.

Best
Thomas

1 Like

Hey Samreen,

hope you’re well. Have you got any news for me?

Best Thomas

Hey Thomas,

I haven’t been able to try out MaryTTS yet, maybe this week, to see if the MATRIX Voice audio jack will work with it.

There are steps in the Rhasspy docs here as well, if you have time.

Best,
Samreen

Hey Samreen,

thank you for your answer. I’m wondering whether going via MaryTTS is the best way. Of course, it could be one of maybe several workarounds. I’ve investigated a bit and found that the issue to play other than 44100 Hz wav files is very much older than my request.

@Romkabouter has already been in touch to this issue with @yoelrc88l:

Unfortunately I cannot see if a solution had been found. However, my issue seems to be a common request. So if a working solution is available I would prefer this instead of a workaround. Do you agree or do you have a different view?

Best
Thomas

I have setup Rhasspy with the audio output through the speaker connectors.

I am using these speakers:

4 Ohm 3W (maybe that should only be 1.5W per channel however?)

I can hear the .wav-files being played, but they sound quite bad with a “crack” etc. On my PC they sound nice.

Is there a problem with the WAV file? Or output format? Or is it the speaker?

Please note that using the volume command
amixer set PCM 100%

does not really change the volume at all. Any advice to this?

Thank you!

Yes and no. I resample everything other than 44100 stereo

Hi Thomas,

What you are saying makes sense.

We had a simple way for the MATRIX Voice speaker output to work with all sampling rates while connected to the Raspberry Pi and that involved using plughw in the default speaker section in /etc/asound.conf as shown below.

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

plughw in ALSA takes care of all the conversions needed to play at 44100 Hz for the MATRIX Voice audio jack output.

I tried to get the above method working with Rhasspy but for some reason using plughw with Rhasspy resulted in no sound output at all. We suspect this may be related to how we input the soundcard /dev/snd directly into the Rhasspy docker container, therefore perhaps negating the plughw feature in ALSA. This may also be the reason why dsnoop does not seem to be working with Rhasspy.

Since I was unsuccessful with the above attempts, I figured MaryTTS might be a good next workaround for the Rhasspy system as plughw does not seem to be working with it. It might help to post this general issue in the Rhasspy community as well to see if anyone knows of a solution.

Best,
Samreen

@SpaceGlider,

It could be the sampling rate of the WAV file as we were discussing in this thread. I doubt it’s your speaker, though you can quickly test that with a stock wav file from your terminal. EDIT: this should work since multiple apps should be able to play audio through the same speakers.

wget https://goo.gl/CDF6sf -O ./audio-sample.wav
aplay -D "hw:2,1" ./audio-sample.wav

It is possible that the volume command is not working due to it being run outside the docker container. You could try to run the bash command inside the container following the steps here.

Best,
Samreen

@Romkabouter

Hey Samreen and Romkabouter,

thank you for your answers. I will do some tests on my own and will post this issue int the Rhasspy community now. I am aware that the Rhasspy team is currently focussed on the new 2.5 release. Maybe they can put my request to the roadmap, if not a solution has already been found.

Thank you again. I will keep you informed.

Best
Thomas

1 Like