How to execute a script stored in slot_programs

Hello, I have a problem using the function which allows to launch a script in an award.ini
I explain what I did like this you can tell me where I made a mistake !!
I tested with 2 scripts: the first a bash and the second in python
I placed them in / profile / en / slot_programs

the bash script:

#!/usr/bin/env bash
pico2wave -l fr-FR -w /tmp/test.wav “$@”
aplay -q /tmp/test.wav
rm /tmp/test.wav

the python script:

#! / usr / bin / env python3
import os
import sys

def main():
phrase=("pico2wave -l fr-FR -w /tmp/test.wav ’ " + sys.argv[1] + “’”)
os.system(“rm /tmp/test.wav >nul 2>&1”)
fichier= os.system(phrase )
os.system(“aplay -q /tmp/test.wav”)


if name == “main”:

both work perfectly in manual call
1- ./ 'Hello how are you "
2- python3 ‘Hello how are you’

But here begins my problems:
I tested various award options in Sentences such as:

$dit moi bonjour
($dit) moi bonjour

Also I then added a SLOT:

“dit”: [

when I test in get intention the log recognizes well:

[DEBUG: 70586664] InboxActor: -> stopped
[DEBUG: 70586660] HermesMqtt: Published intention to hermes / intention / dit
[DEBUG: 70586653] main: {“intention”: {“name”: “dit”, “confidence”: 1.0}, “entities”: [], “text”: “dit moi bonjour”, “raw_text”: " tell me hello “,” recognize_seconds “: 0.015486061998672085,” tokens “: [” says “,” me “,” hello “],” raw_tokens “: [” says “,” me “,” hello “],” speech_confidence " : 1, “slots”: {}, “wakeId”: “”, “siteId”: “default”, “time_sec”: 0.023162364959716797}
[DEBUG: 70586651] InboxActor: -> stopped
[INFO: 69838302] quart.serving: POST / api / text-to-intention 1.1 200 382 65558
[DEBUG: 69838290] InboxActor: -> stopped

but the script is never executed
I don’t see where my mistake is

Hi @arpagor62970

Do you found howto do ?
I try you script shell named but without .sh extension.
So its named dit and with chmod 755 its here :


But when I put on sentences.ini it’s always "Training failed:"

My sentences.ini :


The documentation said no spaces and arguments separated by commas.
The script is same as yours but named “dit” without extension to be compliant with $dit

Nothing else setted or modified.

Thanks for your feedback.

EDIT : Nothing defined in Slot definition
And when I put the script “dit” just the directory upper (as I understood from documentation) and I press “Save sentences” I got :

Training failed: <Task: ini_graph>: TaskError PythonAction Error Traceback (most recent call last): File “/home/pi/rhasspy/.venv/lib/python3.7/site-packages/doit/”, line 424, in execute returned_value = self.py_callable(*self.args, **kwargs) File “/home/pi/rhasspy/rhasspy/train/”, line 354, in do_intents_to_graph graph = intents_to_graph(sentences, replacements) File “/home/pi/rhasspy/.venv/lib/python3.7/site-packages/rhasspynlu/”, line 245, in intents_to_graph exclude_slots_from_counts=exclude_slots_from_counts, File “/home/pi/rhasspy/.venv/lib/python3.7/site-packages/rhasspynlu/”, line 322, in sentences_to_graph count_dict=count_dict, File “/home/pi/rhasspy/.venv/lib/python3.7/site-packages/rhasspynlu/”, line 111, in expression_to_graph count_dict=count_dict, File “/home/pi/rhasspy/.venv/lib/python3.7/site-packages/rhasspynlu/”, line 167, in expression_to_graph assert slot_values, f"Missing slot {slot_values}" AssertionError: Missing slot <rhasspy.train.train_profile..SlotProgram object at 0x71362190>

If I am reading the documentation correctly the script shouldn’t have an extension so it should just be called dit

Sorry, I answered the wrong question. I think the problem is that the output is a wav file not a list that can be used by as a slot

And to be more complete in my answer it is not even returning a wav file, it is playing a wav file and returning nothing to stdout.

The example in the documentation would output:

to stdout

These slot_programs only get called when training to generate slot list for the training. They can not be used for intent handling.

The command option for intent handling allows you to call a programm every time any intent is recognized by rhasspy. For more information regarding this option you can take a look at this part of the documentation:

OK I understand.
But I already use a remote command (Plugin jeeRhasspy of @KiboOst)
I’m not sure that I can add a local command to this remote.

I will search…

Can you not use that to send a text to speech command to Rhasspy ?
Rhasspy has a text to speech http api under /api/text-to-intent .

The short answer is that is not the purpose of slot programs.

The slot programs purpose is to create a slot to use in sentences when you train your model. They are only run during training. As the example shows, if you want a list of colours so that you can say, “Change the colour to red” or some other colour, you write a slot program called colour and a sentence that reads

Change the colour to ($colour)

the slot programs are more for things that change their value between training that may require to be regenerated each time you train to help with speech to text, not text to speech.

What you are trying to do with the slot intent is basically what I started a feature request for here. It is something that seems useful (to me at least) but I have no idea if it will ever be implemented.

I have the same need.
Use remote url with jeedom AND I would like to use some local command to do some generic askink not linked to Jeedom (shutdown/reboot the rhasspy at least, radndom kaamelott citation…).

You can do all that inside Jeedom. For example I have some actions in script plugin to shutdown leds at night, change volume, get a log which is on the rhasspy device, etc. I also have for some intents a skill scenario that send tags to a python script (météo and such). You can run ssh commands on the rhasspy from jeedom, etc.

Hi @KiboOst
Yes I thought about that to run ssh through jeedom.
But it’s a little strange for me to ask to jeedom to launch some local command in Rhasspy.


Yes I can agree.
Then you can make intent recognition to start a script of yours. And in this script you filter intent, sending back jeedom ones to the remote url of jeedom plugin when needed.

I though about that but the pi is for me a volatile device. SD card can fail etc, and it’s very easy to get a new one running in minutes, so having all on jeedom is another appproach.

Then you can make intent recognition to start a script of yours. And in this script you filter intent, sending back jeedom ones to the remote url of jeedom plugin when needed.

Yes it’s another possibility.

Hi @KiboOst,

I go back to this discussion and I would like some informations on howto do all remote action (ssh-keygen on rhasspy but after where and how on jeedom with which account (www-data ?) to authorize the ssh pi@iprhasspy ‘sudo reboot’ without password)
Could you help me to do that or explain ?


EDIT : I succeeded by putting the id_rsa (generated on pi rhasspy and scp on /home/www-data and creating script command)
I don’t know if you did the same.

Hi thanks,

Been wondering about this. I’ve actually created a script and run it as a cron job to write into a standard slot file. I’m guessing that has the same effect? Also I wanted data from a database, tokenisation and number of other features.

Nexr question is, I’d like to (for example) do a nightly retrain from command line, will a restart also retrain? Or is there a command line API to request a retrain?


The reference to the api is here

If you go down to the command api/train you will see that if you POST any value to that command on your rhasspy server it will trigger the server to retrain.

Thanks, I should really read docs more carefully, shouldn’t I?!