mirror of
https://github.com/livekit/agents.git
synced 2026-12-06 05:08:31 +00:00
23 lines
685 B
Python
23 lines
685 B
Python
from urllib.parse import urlencode
|
|
|
|
from .version import __version__ as lk_version
|
|
|
|
|
|
def get_tts_url(base_url: str, voice: str, sample_rate: int) -> str:
|
|
"""Format the TTS endpoint URL with voice, output format, and version params.
|
|
|
|
Args:
|
|
base_url: The base URL for the TTS endpoint.
|
|
voice: The voice model to use.
|
|
sample_rate: The audio sample rate.
|
|
|
|
Returns:
|
|
str: The formatted TTS endpoint URL.
|
|
"""
|
|
query_params: dict[str, str] = {}
|
|
query_params["output_format"] = f"pcm_{sample_rate}"
|
|
query_params["sm-app"] = f"livekit/{lk_version}"
|
|
query = urlencode(query_params)
|
|
|
|
return f"{base_url}/generate/{voice}?{query}"
|