From 006c6db5acc3f5b06091917aab5d1ea82761d3b9 Mon Sep 17 00:00:00 2001 From: Dmitry Avsioukov <7floor@gmail.com> Date: Sun, 11 Aug 2024 20:01:28 +0300 Subject: [PATCH] add callback async_get_supported_voices() --- custom_components/rhvoice/tts.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/rhvoice/tts.py b/custom_components/rhvoice/tts.py index ee4e53a..18c58f4 100644 --- a/custom_components/rhvoice/tts.py +++ b/custom_components/rhvoice/tts.py @@ -8,7 +8,7 @@ import async_timeout import voluptuous as vol from aiohttp import ClientError -from homeassistant.components.tts import PLATFORM_SCHEMA, Provider +from homeassistant.components.tts import PLATFORM_SCHEMA, Provider, Voice, callback from homeassistant.const import ( CONF_HOST, CONF_PORT, @@ -104,6 +104,11 @@ def supported_options(self): """Return list of supported options.""" return SUPPORTED_OPTIONS + @callback + def async_get_supported_voices(self, language: str) -> list[Voice] | None: + """Return a list of supported voices for a language.""" + return [Voice(voice, voice) for voice in SUPPORTED_LANGUAGES[language]] + async def async_get_tts_audio(self, message, language, options=None): """Load TTS from RHVoice.""" websession = async_get_clientsession(self.hass)