MycroftAI / mycroft-core

Mycroft Core, the Mycroft Artificial Intelligence platform.
https://mycroft.ai
Apache License 2.0
6.51k stars 1.27k forks source link

Intent language support #2989

Closed Joanguitar closed 2 years ago

Joanguitar commented 3 years ago

Is your feature request related to a problem? Please describe. Currently Mycroft is set to work with a single language, it would be cool if we could enable it to run in multiple languages simultaneously. I think that since messages already contain the language the easiest step would be to make the intent service make use of the language. By solving this little problem it would already be possible to have a working multi-language Mycroft making use of the voice satellite HiveMind terminal. Once this is solved I would like to help with extending the multiple languages feature to other Mycroft components.

Describe the solution you'd like My solution would be to add a variable "supported_languages" (array) that falls back to the configured Mycroft language (one element array) when not defined (for retro compatibility) and that is used to create multiple instances of the different intent services (padatious, adapt...) each one configured for each language in "supported languages", then when the utterance is matched to the intent it would use the intent service trained for the message language. I will fork the repository and start working on it.

Describe alternatives you've considered What I described above is simple and I think it is the obvious step to take. I would like to contribute by implementing this.

Additional context The steps are simple, first add an optional addition variable "supported_languages" to the config file, then implementing the use of this variable for the different intent services, first padatious, then adapt, ...

ChanceNCounter commented 3 years ago

I would encourage you to take a look at the way Lingua Franca handles supported and currently-loaded languages, as it was designed to slot into this. I made some assumptions about what it would look like, but I think they're pretty straightforward. If not, I'm happy to go into it.

krisgesling commented 3 years ago

Hey there, thanks for helping to improve Mycroft.

Proper multi-lingual support is a long term dream so if we can make roads towards it then that would be great. However I also want to warn you that it's not an immediate priority for the project and we're really focusing on stability and bugfixes. So the support that we can provide will be limited for the moment.

Of course there is also a great bunch of people around, many of whom speak multiple languages, so definitely throw any questions out here or in Chat.

I like your plan of doing it in stages rather than trying to tackle the entire thing in one hit too. It makes it more manageable both for yourself or others working on it, and for the people reviewing those changes.

Another component of this that we have on our radar is improving the configuration system and ensuring it's consistent across the code base so that if changes are made, say "primary_language" then that will be picked up by everything that should consume it.

Joanguitar commented 3 years ago

I'm glad to announce that I already managed to make it work yesterday night in my personal fork and I will be using it for a while together with my multi-language fork of HiveMind-voice-sat to test for bugs.

It works exactly as I described, you can define an optional new field "supported_langs" (in my config file I set for testing I have "supported_langs": ["en-us", "es-es", "ca-es"],) with an array of languages you want the intent service to be able to work with (if not specified [self.lang] is used instead for consistency), and if a "recognizer:loop" message contains the field "lang" (which already does by default) the intent service will use that language to match that skill, the skill then replies in that language and includes the field "lang" in the reply message for the the audio client to feed it to the TTS (not implemented in Mycroft, but working with my fork of HiveMind-voice-sat).

Feel free to test my fork and send me any bugs or suggestions so I can fix them. Hopefully I will feel confident to do a PR within not too much time. Please note that Mycroft's wake work doesn't propagate the language of the detected word and that therefore STT and TTS are only configured to adapt to language, so if you want to test it I recommend you to either artificially inject messages in the messagebus with your desired characteristics or that you use the HiveMind tool I mentioned above.

JarbasAl commented 3 years ago

fwiw this is also fully functional in HolmesV, slightly different approach but goes even more in depth

https://github.com/HelloChatterbox/HolmesV/commit/b9abbcdc1d1efe869aeab9dcb1acb3c4b62d7d83

https://github.com/HelloChatterbox/HolmesV/commit/889c25a613db7c5af02a3139f9b109584928cd6b

Joanguitar commented 2 years ago

There's no interest to implement this in the short term for Mycroft and it's already working for HolmesV, so I'm switching to HolmesV and closing this issue.