Skip to content
Open
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
46 changes: 46 additions & 0 deletions livekit-plugins/livekit-plugins-rime/livekit/plugins/rime/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,58 @@ def update_options(
*,
model: NotGivenOr[TTSModels | str] = NOT_GIVEN,
speaker: NotGivenOr[str] = NOT_GIVEN,
lang: NotGivenOr[TTSLangs | str] = NOT_GIVEN,
# Arcana parameters
repetition_penalty: NotGivenOr[float] = NOT_GIVEN,
temperature: NotGivenOr[float] = NOT_GIVEN,
top_p: NotGivenOr[float] = NOT_GIVEN,
max_tokens: NotGivenOr[int] = NOT_GIVEN,
sample_rate: NotGivenOr[int] = NOT_GIVEN,
# Mistv2 parameters
speed_alpha: NotGivenOr[float] = NOT_GIVEN,
reduce_latency: NotGivenOr[bool] = NOT_GIVEN,
pause_between_brackets: NotGivenOr[bool] = NOT_GIVEN,
phonemize_between_brackets: NotGivenOr[bool] = NOT_GIVEN,
) -> None:
if is_given(model):
self._opts.model = model

if model == "arcana" and self._opts.arcana_options is None:
self._opts.arcana_options = _ArcanaOptions()
elif model == "mistv2" and self._opts.mistv2_options is None:
self._opts.mistv2_options = _Mistv2Options()

if is_given(speaker):
self._opts.speaker = speaker

if self._opts.model == "arcana" and self._opts.arcana_options is not None:
if is_given(repetition_penalty):
self._opts.arcana_options.repetition_penalty = repetition_penalty
if is_given(temperature):
self._opts.arcana_options.temperature = temperature
if is_given(top_p):
self._opts.arcana_options.top_p = top_p
if is_given(max_tokens):
self._opts.arcana_options.max_tokens = max_tokens
if is_given(lang):
self._opts.arcana_options.lang = lang
if is_given(sample_rate):
self._opts.arcana_options.sample_rate = sample_rate

elif self._opts.model == "mistv2" and self._opts.mistv2_options is not None:
if is_given(lang):
self._opts.mistv2_options.lang = lang
if is_given(sample_rate):
self._opts.mistv2_options.sample_rate = sample_rate
if is_given(speed_alpha):
self._opts.mistv2_options.speed_alpha = speed_alpha
if is_given(reduce_latency):
self._opts.mistv2_options.reduce_latency = reduce_latency
if is_given(pause_between_brackets):
self._opts.mistv2_options.pause_between_brackets = pause_between_brackets
if is_given(phonemize_between_brackets):
self._opts.mistv2_options.phonemize_between_brackets = phonemize_between_brackets


class ChunkedStream(tts.ChunkedStream):
"""Synthesize using the chunked api endpoint"""
Expand Down
Loading