get_tts_url (speechmatics/utils.py)

livekit/agents · livekit-plugins/livekit-plugins-speechmatics/livekit/plugins/speechmatics/utils.py · python · Apache-2.0
voice, Voice / Speech

Builds a Speechmatics TTS endpoint URL with voice and sample rate.

# Source: https://github.com/livekit/agents | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
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 = {}
    query_params["output_format"] = f"pcm_{sample_rate}"
    query_params["sm-app"] = f"livekit/{lk_version}"
    query = urle

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key