TTS Plugins
All Mycroft TTS plugins need to define a class based on the TTS base class from mycroft.tts
The super()
call does some setup adding specific options to how Mycroft will preprocess the sentence.
audio_ext
: filetype of output, possible options 'wav' and 'mp3'.phonetec_spelling
, True if Mycroft should preprocess some difficult to pronounce words (eg spotify) or provide the raw text to the TTS.ssml_tags
: list of valid SSML tags for the TTS if any, otherwise None.validator
: a special class that verifies that the TTS is working in the current configuration.
It also registers the module's config from the Mycroft configuration in self.config
as well as the current language in self.lang
For the following config snippet
Mycroft will register the "example_tts"
part in the TTS's self.config
get_tts()
get_tts()
The get_tts()
method will be called by Mycroft to generate audio and (optionally) phonemes. This is the main method that the plugin creator needs to implement. It is called with:
sentence
(str): a piece of text to turn into audio.wav_file
(str): where the plugin should store the generated audio data.
This method should generate audio data and return a Tuple (wav_file, visemes)
:
wav_file
(str): path to written data (generally the input argument)visemes
(list): viseme list for synthesized audio
As an example see the get_tts
method for Mimic2.
TTS Validator
To check if the TTS can be used, a validator class is needed. This should inherit from mycroft.tts.TTSValidaor
. It will be called with the TTS class as argument and will store it in self.tts
.
The following is the bare minimum implementation:
Entry point
To make the class detectable as an TTS plugin, the package needs to provide an entry point under the mycroft.plugin.tts
namespace.
Where example_tts
is is the TTS module name for the plugin, my_tts
is the Python module and myTTS
is the class in the module to return.
Last updated