Intent handling with command

This folder:

is not known in the docker container.

Please post your log from Rhasspy, your whole log from where the intent is Recognized to the end of the session.
There might be an obvious error in it.

I have the 0.mp3 file with chmod 777 in the “profiles” folder and in “profiles/es

In all WAV I put:
${RHASSPY_PROFILE_DIR}/0.mp3

It does not work, then I put:
propiles/0.mp3
and then
/propiles/0.mp3

Nothing works. It only works when I place the originals:

${RHASSPY_BASE_DIR}/etc/wav/beep_hi.wav
${RHASSPY_BASE_DIR}/etc/wav/beep_lo.wav
${RHASSPY_BASE_DIR}/etc/wav/beep_error.wav

With relation to the logs, I eliminate them (the blue button “CLEAR”), I can talk again, I copy them and send them, it does not matter, right?

Rhasspy only plays wav files, so no luck with mp3.

Correct about the logs, we need more verbose logs. Because there can be an error in it which causes your problem with the intent command

Perfect, I will generate the WAV.

With regard to the commands, you can show me an example that works for you? Please. One simple

The .wav has worked, but, the Handling command does not work.
Work: ${RHASSPY_PROFILE_DIR}/0.wav
It does not work: ${RHASSPY_PROFILE_DIR}/robot.py

Both have all the permissions.

The command starts with: #!/usr/bin/env python3

So I think the problem is something about the code, you can show me one that works, please? So I replenish it and see if it is that or another.

Again: please post the logs from Rhasspy.
If there is an error, it will be shown there.

Hmm that is a bit strange, maybe it is a setting to active more debug info.
I’ll have to check.

In my log there are a lot more message (about sending bytes to various topics)

Would it be too much to ask you to show me the example that works for you? Please. So I tell you the exact configuration and I rule out that it is a problem in my environment or not. Please.

This works for me (with handle.py in my profile directory [1]):

{
    "handle": {
        "command": {
            "program": "${RHASSPY_PROFILE_DIR}/handle.py"
        },
        "system": "command"
    }
}

[1] This is ~/.config/rhasspy/profiles/en on my machine

I do not use command and intent handler, so I have no example.
The example code you have should run fine.

I give up. Nothing works.

Can you show me what’s in your profile JSON? Did my example not work?

1 Like

I’ll try it out as well with the example and see what works.
You are using docker right?

1 Like

Yes, I am using Docker. The problem is that I think I have everything as you tell me. Because I changed the profile.json manually exactly as you told me, and I also tried when the web configurations make the change (there are no errors in this step, because it is programmed by you in Docker).

Above the python file I put what you told me so that it recognizes that it must be run with Python3 (#!/usr/bin/env python3), it has all the permissions (I made sure of that, all the folders before reaching the final path have 777 permissions), and I also made sure of which path is the correct one because it has the same format as the WAV of the wakeword (this works and is in the same path of the profile_dir… ${RHASSPY_PROFILE_DIR}/).

I am using the Home Assistant addon, so it will be a bit different for me :slight_smile:

Can you make screenshot of your Rhasspy settings? That might help

I have changed a coupe of lines in handle.py, my intent is “Locations” and I have added some line to print the chosen reply:

elif intent == "Locations":
    replies = ['Hi!', 'Hello!', 'Hey there!', 'Greetings.']
    reply = random.choice(replies) 
    print(reply)
    speech(reply)

This is the output.

The file handle.py is set to ${RHASSPY_PROFILE_DIR}/handle.py

This is where the file is:

So if you set it to ${RHASSPY_PROFILE_DIR}/handle.py and put it in you active profile, see what happens.

please also attach the docker logs.: docker logs rhasspy

1 Like

Thanks to that log code I am seeing that it passes behind. I see that if you print the text you indicate, the problem is that it does not play the audio.

I have tried two things, in the first case what I did was to place the direct patch, and in 2nd case place the same as I put on the wakeup.

In the 1st case this comes out:

[DEBUG:2021-04-20 14:47:29,495] rhasspyremote_http_hermes: ['/profiles/es/handle.py']
[DEBUG:2021-04-20 14:47:29,503] rhasspywake_raven_hermes: Receiving audio
[DEBUG:2021-04-20 14:47:29,755] rhasspyremote_http_hermes: /home/pi/.config/rhasspy/profiles/es/wake.wav: No such file or directory
[WARNING:2021-04-20 14:47:29,756] rhasspyremote_http_hermes: Output: b'Hey there!\ntest-test-test\n'

cd /home/pi/.config/rhasspy/profiles/es/
ls
deepspeech          handle.py               profile.json  sentences.ini     supervisord.log  wake.wav

In the 2nd case this comes out:

[DEBUG:2021-04-20 14:42:19,892] rhasspyremote_http_hermes: Traceback (most recent call last):
  File "/profiles/es/handle.py", line 16, in <module>
    os.system(f"aplay ${RHASSPY_PROFILE_DIR}/wake.wav")
NameError: name 'RHASSPY_PROFILE_DIR' is not defined
[WARNING:2021-04-20 14:42:19,893] rhasspyremote_http_hermes: Output: b'Hi!\n'
[DEBUG:2021-04-20 14:42:21,450] rhasspy-wake-raven: Exiting refractory period

As I said, thanks to that logs command I can see that if it works (I did not know that command, I’m new in this world, so sorry for not seeing it before).

What does not work is the execution of the commands, I do not know why.

ok cool, so handly.py is working :slight_smile:
The ${RHASSPY_PROFILE_DIR} is not found in handle.py, because that variable is not known there.
Try it with
os.system(f"aplay /home/pi/.config/rhasspy/profiles/es/sounds/wake.wav")
Assuming you have that in your profile, please check the path.

What is it that you want to achieve? The original code:
speech(random.choice(replies))
should activate the Text to speech

Does this work in a terminal?
aplay /home/pi/.config/rhasspy/profiles/es/sounds/wake.wav

if not, the python script will certainly not work

In the log it does not work:

[DEBUG:2021-04-20 14:58:24,629] rhasspyremote_http_hermes: /home/pi/.config/rhasspy/profiles/es/wake.wav: No such file or directory

In Terminal works and reproduces well:

    aplay /home/pi/.config/rhasspy/profiles/es/wake.wav
    Playing WAVE '/home/pi/.config/rhasspy/profiles/es/wake.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo

Is it honestly rare, there is some other way of playing audio? I will not use TTS.