Mycroft AI
  • Documentation
  • About Mycroft AI
    • Why use Mycroft AI?
    • Glossary of terms
    • Contributing
    • FAQ
  • Using Mycroft AI
    • Get Mycroft
      • Mark II
        • Mark II Dev Kit
      • Mark 1
      • Picroft
      • Linux
      • Mac OS and Windows with VirtualBox
      • Docker
      • Android
    • Pairing Your Device
    • Basic Commands
    • Installing New Skills
    • Customizations
      • Configuration Manager
      • mycroft.conf
      • Languages
        • Français (French)
        • Deutsch (German)
      • Using a Custom Wake Word
      • Speech-To-Text
      • Text-To-Speech
    • Troubleshooting
      • General Troubleshooting
      • Audio Troubleshooting
      • Wake Word Troubleshooting
      • Log Files
      • Support Skill
      • Getting more support
  • Skill Development
    • Voice User Interface Design Guidelines
      • What can a Skill do?
      • Design Process
      • Voice Assistant Personas
      • Interactions
        • Intents
        • Statements and Prompts
        • Confirmations
      • Conversations
      • Error Handling
      • Example Interaction Script
      • Prototyping
      • Design to Development
    • Development Setup
      • Python Resources
      • Your First Skill
    • Skill Structure
      • Lifecycle Methods
      • Logging
      • Skill Settings
      • Dependencies
        • Manifest.yml
        • Requirements files
      • Filesystem access
      • Skill API
    • Integration Tests
      • Test Steps
      • Scenario Outlines
      • Test Runner
      • Reviewing the Report
      • Adding Custom Steps
      • Old Test System
    • User interaction
      • Intents
        • Padatious Intents
        • Adapt Intents
      • Statements
      • Prompts
      • Parsing Utterances
      • Confirmations
      • Conversational Context
      • Converse
    • Displaying information
      • GUI Framework
      • Show Simple Content
      • Mycroft-GUI on a PC
      • Mark 1 Display
    • Advanced Skill Types
      • Fallback Skill
      • Common Play Framework
      • Common Query Framework
      • Common IoT Framework
    • Mycroft Skills Manager
      • Troubleshooting
    • Marketplace Submission
      • Skills Acceptance Process
        • Information Review Template
        • Code Review Template
        • Functional Review Template
        • Combined Template
      • Skill README.md
    • FAQ
  • Mycroft Technologies
    • Technology Overview
    • Roadmap
    • Mycroft Core
      • MessageBus
      • Message Types
      • Services
        • Enclosure
        • Voice Service
        • Audio Service
        • Skills Service
      • Plugins
        • Audioservice Plugins
        • STT Plugins
        • TTS Plugins
        • Wake Word Plugins
      • Testing
      • Legacy Repo
    • Adapt
      • Adapt Examples
      • Adapt Tutorial
    • Lingua Franca
    • Mimic TTS
      • Mimic 3
      • Mimic 2
      • Mimic 1
      • Mimic Recording Studio
    • Mycroft GUI
      • Remote STT and TTS
    • Mycroft Skills Kit
    • Mycroft Skills Manager
    • Padatious
    • Precise
    • Platforms
Powered by GitBook
On this page
  • get_tts()
  • TTS Validator
  • Entry point

Was this helpful?

  1. Mycroft Technologies
  2. Mycroft Core
  3. Plugins

TTS Plugins

PreviousSTT PluginsNextWake Word Plugins

Last updated 4 years ago

Was this helpful?

All Mycroft TTS plugins need to define a class based on the TTS base class from mycroft.tts

from mycroft.tts import TTS

class myTTS(TTS):
    def __init__(self, lang, config):
        super().__init__(lang, config, validator, audio_ext='wav',
                         phonetic_spelling=False, ssml_tags=None)
        # Any specific init code goes here

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 in self.config as well as the current language in self.lang

For the following config snippet

  "tts": {
    "module": "example_tts",
    "example_tts": {
      ...
    }
  }

Mycroft will register the "example_tts" part in the TTS's self.config

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

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:

class MyValidator(TTSValidator):
    def get_tts_class(self):
        # Should return a reference to the TTS class it's inteded to validate.

    def validate_lang(self):
        # Raise exception if `self.tts.lang` is not supported.

    def validate_connection(self):
        # Check that the software needed for the TTS is reachable,
        # be it a local executable, python module or remote server and
        # if not available raise an exception.

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.

setup([...],
      entry_points = {'mycroft.plugin.tts': 'example_tts = my_tts:myTTS'}
      )

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.

As an example see the .

Mycroft configuration
get_tts method for Mimic2