synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
948 stars 101 forks source link

slot/tag/synonyme #81

Closed KiboOst closed 4 years ago

KiboOst commented 4 years ago

I would need some clarification on slots I guess.

My goal is to have several intents (around 20) that all works with some pre-defined slots. Slot example: house_room = (kitchen | living-room) device_name = (tv | music)

So I can use these slots in different intent sentences.

But how can I set slot items synonyms, and always have the same value in the json for all synonyms ?

exemple, the "tv" in device_name can be "television", how I set such synonyms in device_name slot ? And how can I assure that what ever synonym I use, the intent recognized json slot always have the same name so further test is working ?

With snips, a slot got several items, with its synonyms, and the first item name is the name used in the returned json. for example: house_room { {salon, séjour}, {dehors, exterieur}, {salle, salle à manger, la salle} } and when testing house_room in resulting recognized intent I just have to test if slot(house_room) is salon, or dehors, or salle.

How to set such slots into rhasspy ?

mathquis commented 4 years ago

I do exactly that 😊

I create a room file in the slots folder of the profile with this content:

( le salon | la salle | le séjour ):livingroom
( le jardin | l’extérieur | dehors ):garden
...

And in the intents I simply use: allume dans ($room){zone}

For the utterance allume dans le jardin, the slot zone will have the value garden.

Hope this helps.

KiboOst commented 4 years ago

Amazing, will test that !! Didn’t see in the doc that we could create one file per slot, even better ! Thanks

KiboOst commented 4 years ago

Hmm traning doesn't work

I have created different slots files (without extension)

in UI, slots I have all my slots

"house_room": [ "( salon | séjour ):salon", "( sdbs | salles de bains ):sdbs", "( bureau ):bureau", "( en bas | rez de chaussée | du bas | bas ):en bas",

in sentences I have this (can't manage to save intent files in profile /intents) [GetTime] quelle heure est-il il est quelle heure

[lightsSetJeedom] allume la lumière de ($house_room){house_room} allume la lumière dans la ($house_room){house_room} allume la lumière dans la ($house_room){house_room} et dans la ($house_room){house_room} allume ($lights_type){lights_type} les lumières ($house_room){house_room} mets de la lumière dans ($house_room){house_room}

But traning always send this error:

ERROR:main:Training failed: : TaskFailed Command failed: 'ngrammake /home/pi/.config/rhasspy/profiles/fr/intent.fst.counts /home/pi/.config/rhasspy/profiles/fr/intent.fst.model' returned 1 Traceback (most recent call last): File "/home/pi/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1471, in full_dispatch_request result = await self.dispatch_request(request_context) File "/home/pi/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1519, in dispatchrequest return await handler(**request.view_args) File "app.py", line 571, in api_train raise Exception(f"Training failed: {result.reason}") Exception: Training failed: : TaskFailed Command failed: 'ngrammake /home/pi/.config/rhasspy/profiles/fr/intent.fst.counts /home/pi/.config/rhasspy/profiles/fr/intent.fst.model' returned 1

KiboOst commented 4 years ago

Well, really can't get the logic in slots:

This works:

( salon | sejour ):salon ( dehors | exterieur ):dehors

This crash:

( salon | sejour ):salon ( jardin | terrasse ):jardin ( dehors | exterieur ):dehors

with in sentences:

[lightsSetJeedom] allume la lumière de ($house_room){house_room}

synesthesiam commented 4 years ago

Let me take a look. I've been fixing bugs lately with sequence substitution, and I may have fixed it already. Thanks for providing so much detail!

mathquis commented 4 years ago

@KiboOst I have tested your example and it works perfectly on the latest Rhasspy docker image (no training crash with ngrammake).

It seems you are not using the Docker image though.

Did you build OpenFST and provided it in the PATH?

What happens when you run this command in the Pi bash: ngrammake /home/pi/.config/rhasspy/profiles/fr/intent.fst.counts /home/pi/.config/rhasspy/profiles/fr/intent.fst.model

As a last resort, you can re-download the profile files via the Settings tab and re-train (I sometimes solved some strange training cache issues doing this).

@synesthesiam It might be useful to log command execution stdout/stderr in the Rhasspy logs (using a rhasspy.log_level option in the profile.json file?). I'll create a new issue for this ;)

synesthesiam commented 4 years ago

Seems to be fixed now.