Skip to main content

Text-to-speech entity

A text-to-speech (TTS) entity enables Home Assistant to speak to you.

A text-to-speech entity is derived from the homeassistant.components.tts.TextToSpeechEntity.

Properties

tip

Properties should always only return information from memory and not do I/O (like network requests).

NameTypeDefaultDescription
supported_languageslist[str]RequiredThe supported languages of the TTS service.
default_languagestrRequiredThe default language of the TTS service.
supported_optionslist[str]NoneThe supported options like voice, emotions of the TTS service.
default_optionsMapping[str, Any]NoneThe default options of the TTS service.

Methods

Get supported voices

This method is used to return a list of supported voices for a language of a TTS service.

class MyTextToSpeechEntity(TextToSpeechEntity):
"""Represent a Text To Speech entity."""

@callback
def async_get_supported_voices(self, language: str) -> list[str] | None:
"""Return a list of supported voices for a language."""

Get TTS audio

The get tts audio method is used to generate an audio file from a text message using a TTS service.

class MyTextToSpeechEntity(TextToSpeechEntity):
"""Represent a Text To Speech entity."""

def get_tts_audio(
self, message: str, language: str, options: dict[str, Any]
) -> TtsAudioType:
"""Load tts audio file from the engine."""

async def async_get_tts_audio(
self, message: str, language: str, options: dict[str, Any]
) -> TtsAudioType:
"""Load tts audio file from the engine."""