Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions livekit-plugins/livekit-plugins-azure/livekit/plugins/azure/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class _TTSOptions:
deployment_id: str | None
prosody: NotGivenOr[ProsodyConfig]
style: NotGivenOr[StyleConfig]
lexicon_uri: NotGivenOr[str]
auth_token: str | None = None

def get_endpoint_url(self) -> str:
Expand All @@ -132,6 +133,7 @@ def __init__(
sample_rate: int = 24000,
prosody: NotGivenOr[ProsodyConfig] = NOT_GIVEN,
style: NotGivenOr[StyleConfig] = NOT_GIVEN,
lexicon_uri: NotGivenOr[str] = NOT_GIVEN,
speech_key: str | None = None,
speech_region: str | None = None,
speech_endpoint: str | None = None,
Expand Down Expand Up @@ -184,6 +186,7 @@ def __init__(
language=language,
prosody=prosody,
style=style,
lexicon_uri=lexicon_uri,
auth_token=speech_auth_token,
)

Expand All @@ -202,6 +205,7 @@ def update_options(
language: NotGivenOr[str] = NOT_GIVEN,
prosody: NotGivenOr[ProsodyConfig] = NOT_GIVEN,
style: NotGivenOr[StyleConfig] = NOT_GIVEN,
lexicon_uri: NotGivenOr[str] = NOT_GIVEN,
) -> None:
if is_given(voice):
self._opts.voice = voice
Expand All @@ -213,6 +217,8 @@ def update_options(
if is_given(style):
style.validate()
self._opts.style = style
if is_given(lexicon_uri):
self._opts.lexicon_uri = lexicon_uri

def _ensure_session(self) -> aiohttp.ClientSession:
if not self._session:
Expand Down Expand Up @@ -243,6 +249,10 @@ def _build_ssml(self) -> str:
f'xml:lang="{lang}">'
)
ssml += f'<voice name="{self._opts.voice}">'

if is_given(self._opts.lexicon_uri):
ssml += f'<lexicon uri="{self._opts.lexicon_uri}"/>'

if is_given(self._opts.style):
degree = f' styledegree="{self._opts.style.degree}"' if self._opts.style.degree else ""
ssml += f'<mstts:express-as style="{self._opts.style.style}"{degree}>'
Expand Down