Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal for language support #1

Open
JonahKr opened this issue May 23, 2020 · 5 comments
Open

Proposal for language support #1

JonahKr opened this issue May 23, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@JonahKr
Copy link
Contributor

JonahKr commented May 23, 2020

I created a component for homeassistant once and really likes the way they handle translations.
more detailed info >here
The basic file structure is for example:

  • skillDir /skill.py
  • skillDir / strings.json - this file contains a template(English) with all unique sentences
  • skillDir / lang - this directory contains all translation files
  • skillDir / lang / de.json - this file contains the german translated version of strings.json

Obviously we don't have the userbase to use platforms like Lokalize but this can just as easy be replaced by merging pullrequests to the skill repositories.

However the intent Json contains no information about which language is being used. One ugly way would be reading it from the profil but we still wouldn't know which profile is the active one.(if there are multiple ones) Maybe it would be possible to add a "lang" field in the Intent JSON with the language abbreviation (like en for english or de for german) on the rhasspy side of things.

These translation files could contain slots and sentences for an automatic implementation as well.

@koenvervloesem
Copy link
Member

koenvervloesem commented May 24, 2020

Yes, I was thinking about something like this, but without the JSON (which is not very human-friendly).

I'm considering using Python's gettext support for translating text before sending it to the TTS. This will also let non-developers contribute translations easier because many translation tools support gettext .po files.

For the sentences for an intent I would create a sentences.ini file for each language the app supports.

This could result in a directory structure such like this:

lang
├── de
│   ├── app.po
│   └── sentences.ini
└── en
    ├── app.po
    └── sentences.ini

But for all this to happen transparently Rhasspy should indeed add a lang attribute to the relevant MQTT messages. I have opened an issue here: rhasspy/rhasspy-hermes#11.

With gettext we also can change the language on the fly, so if every intent has a lang attribute and we check it each time, the app doesn't even have to restart after changing your language profile in Rhasspy.

@JonahKr
Copy link
Contributor Author

JonahKr commented May 25, 2020

I didn't know about gettext... But after reading through the docs a bit it definitely seems like a better(and already well implemented) option.

@koenvervloesem koenvervloesem added the enhancement New feature or request label May 26, 2020
@maxbachmann
Copy link
Member

I like this idea. Using something standardised like gettext as you proposed, since it is supported by most translation systems without any extra effort. So it would be possible to translate skill e.g. with weblate or similar web applications (essentially what mycroft does aswell).

For the sentences.ini file I think it would be good to be able to have multiple sentence and multiple slot files.

@EinfachArne
Copy link

Thanks a lot for the input regarding language support. I made a first implementation on my skill but the sentences.ini files are still missing because I am looking for a way to load them into Rhasspy on start.

https://github.com/EinfachArne/rhasspy-openhab-skill/tree/develop

@koenvervloesem
Copy link
Member

koenvervloesem commented Jun 16, 2021

@EinfachArne I actually wrote something quite similar a while ago while testing the new lang attribute in the Hermes messages. Your implementation is very nice! Maybe it's an idea to add your getTranslator function to Rhasspy Hermes App.

Retraining the sentences.ini file on the fly with an MQTT message is indeed something I'd very much like (see rhasspy/rhasspy-hermes#12). Then we can really make the process of installing new apps quite easy, with as less user interaction as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants