Spitch TTS plugin implementing LiveKit’s TTS interface with streaming audio generation.
# 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 __future__ import annotations
import uuid
from dataclasses import dataclass
import httpx # spitch requires httpx<1 and isinstance-checks this Timeout
import spitch
from livekit.agents import (
DEFAULT_API_CONNECT_OPTIONS,
APIConnectionError,
APIConnectOptions,
APIStatusError,
APITimeoutError,
LanguageCode,
tts,
)
from spitch import AsyncSpitch
SAMPLE_RATE = 24_000
NUM_CHANNELS = 1
MIME_TYPE = "audio/mpeg"
@dataclass
class _TTSOptions:
language: LanguageCode
voice: str
class TTS(tts.TTS):
def __init__(self, *, language: str = "en", voice:
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key