Skip to content

Commit

Permalink
Add supported_languages parameter to STT and TTS base classes (#3059)
Browse files Browse the repository at this point in the history
* Add `supported_languages` parameter to STT and TTS base classes

* Refactor `supported_languages` to `available_languages` and updated docstring to be more precise
  • Loading branch information
NeonDaniel committed Feb 28, 2022
1 parent dd7f7ab commit eb97bb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mycroft/stt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ def __init__(self):
self.recognizer = Recognizer()
self.can_stream = False

@property
def available_languages(self) -> set:
"""Return languages supported by this STT implementation in this state
This property should be overridden by the derived class to advertise
what languages that engine supports.
Returns:
set: supported languages
"""
return set()

@staticmethod
def init_language(config_core):
"""Helper method to get language code from Mycroft config."""
Expand Down
12 changes: 12 additions & 0 deletions mycroft/tts/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ def __init__(self, lang, config, validator, audio_ext='wav',
)
self.cache.clear()

@property
def available_languages(self) -> set:
"""Return languages supported by this TTS implementation in this state
This property should be overridden by the derived class to advertise
what languages that engine supports.
Returns:
set: supported languages
"""
return set()

def load_spellings(self):
"""Load phonetic spellings of words as dictionary."""
path = join('text', self.lang.lower(), 'phonetic_spellings.txt')
Expand Down

0 comments on commit eb97bb3

Please sign in to comment.