1
mirror of https://github.com/home-assistant/core synced 2024-07-12 07:21:24 +02:00

Import tts (#64212)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-18 07:01:28 +01:00 committed by GitHub
parent c3fc7becb6
commit 8bcf495caf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -305,8 +305,11 @@ class CastDevice(MediaPlayerEntity):
tts_base_url = None
url_description = ""
if "tts" in self.hass.config.components:
# pylint: disable=[import-outside-toplevel]
from homeassistant.components import tts
with suppress(KeyError): # base_url not configured
tts_base_url = self.hass.components.tts.get_base_url(self.hass)
tts_base_url = tts.get_base_url(self.hass)
with suppress(NoURLAvailableError): # external_url not configured
external_url = get_url(self.hass, allow_internal=False)

View File

@ -678,6 +678,6 @@ class TextToSpeechView(HomeAssistantView):
return web.Response(body=data, content_type=content)
def get_base_url(hass):
def get_base_url(hass: HomeAssistant) -> str:
"""Get base URL."""
return hass.data[BASE_URL_KEY] or get_url(hass)