TTS: allow resolving engine and test supported options (#90539)

TTS: allow resolving engine
This commit is contained in:
Paulus Schoutsen 2023-03-31 14:34:42 -04:00 committed by GitHub
parent 44eaf70625
commit 8018be28ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 8 deletions

View file

@ -40,16 +40,12 @@ def generate_media_source_id(
cache: bool | None = None,
) -> str:
"""Generate a media source ID for text-to-speech."""
from . import async_resolve_engine # pylint: disable=import-outside-toplevel
manager: SpeechManager = hass.data[DOMAIN]
if engine is not None:
pass
elif not manager.providers:
raise HomeAssistantError("No TTS providers available")
elif "cloud" in manager.providers:
engine = "cloud"
else:
engine = next(iter(manager.providers))
if (engine := async_resolve_engine(hass, engine)) is None:
raise HomeAssistantError("Invalid TTS provider selected")
manager.process_options(engine, language, options)
params = {