MycroftAI / mycroft-core

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

Add event handlers to query available STT/TTS languages #3104

Open NeonDaniel opened 2 years ago

NeonDaniel commented 2 years ago

Is your feature request related to a problem? Please describe. This feature would add functionality for skills or other modules to query what languages are available for STT or TTS.

Describe the solution you'd like Messagebus event handlers would be the simplest method for this so the STT and TTS modules can query loaded plugins directly. i.e.:

bus.on('mycroft.get_tts_langs`, handle_get_tts_langs)

def handle_get_tts_langs(self, message):
    langs = [] if not hasattr(tts, "available_languages") else tts.available_languages
    bus.emit(message.reply({"available_languages": langs}

Describe alternatives you've considered An alternative method would be to load the plugin (determined from config) and check the value directly, but this creates another instance unnecessarily and requires more code to be duplicated anywhere the check is needed. It also is more error-prone than querying running services (config changes/overrides, etc.)

Additional context This request is related to a skill for changing languages that I'm working on refactoring (https://github.com/NeonGeckoCom/skill-translation)

Relates to: https://github.com/MycroftAI/mycroft-core/pull/3059 Potential partial solution for: https://github.com/MycroftAI/mycroft-core/issues/2703 https://github.com/MycroftAI/mycroft-core/issues/1898