tts.say to use media source URLs (#70382)
This commit is contained in:
parent
e387e6d332
commit
9303e35a7d
7 changed files with 215 additions and 101 deletions
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import mimetypes
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from yarl import URL
|
||||
|
||||
|
@ -46,17 +46,19 @@ class TTSMediaSource(MediaSource):
|
|||
raise Unresolvable("No message specified.")
|
||||
|
||||
options = dict(parsed.query)
|
||||
kwargs = {
|
||||
kwargs: dict[str, Any] = {
|
||||
"engine": parsed.name,
|
||||
"message": options.pop("message"),
|
||||
"language": options.pop("language", None),
|
||||
"options": options,
|
||||
}
|
||||
if "cache" in options:
|
||||
kwargs["cache"] = options.pop("cache") == "true"
|
||||
|
||||
manager: SpeechManager = self.hass.data[DOMAIN]
|
||||
|
||||
try:
|
||||
url = await manager.async_get_url_path(**kwargs) # type: ignore[arg-type]
|
||||
url = await manager.async_get_url_path(**kwargs)
|
||||
except HomeAssistantError as err:
|
||||
raise Unresolvable(str(err)) from err
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue