mirror of
https://github.com/livekit/agents.git
synced 2026-12-06 03:28:34 +00:00
Migrate provider WebSocket handling to shared typed protocols, pooling, pacing, and idle timers. Preserve SmallestAI continuations with response-based silence completion and isolated segments. Keep connection acquisition, reconnect controls, stream cleanup, and host wrapper ownership safe across cancellation. Consolidate provider interfaces and typed MCP contracts. Normalize pending speech boundaries and preserve conversation identity, ordering, late results, and acknowledged checkpoints across overlapping voice runs. Extend deterministic regressions, storage observations, and lifecycle documentation. Validation: rebuilt extension; 2900 Python tests passed; formatting, lint, and type checks passed. Rust, binding, codegen, and deterministic simulation checks are recorded in the audit and lifecycle verification records.
191 lines
4.1 KiB
Python
191 lines
4.1 KiB
Python
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
DeepgramModels = Literal[
|
|
"nova-general",
|
|
"nova-phonecall",
|
|
"nova-meeting",
|
|
"nova-2-general",
|
|
"nova-2-meeting",
|
|
"nova-2-phonecall",
|
|
"nova-2-finance",
|
|
"nova-2-conversationalai",
|
|
"nova-2-voicemail",
|
|
"nova-2-video",
|
|
"nova-2-medical",
|
|
"nova-2-drivethru",
|
|
"nova-2-automotive",
|
|
"nova-2-atc",
|
|
"nova-3",
|
|
"nova-3-general",
|
|
"nova-3-medical",
|
|
"nova-3-multilingual",
|
|
"enhanced-general",
|
|
"enhanced-meeting",
|
|
"enhanced-phonecall",
|
|
"enhanced-finance",
|
|
"base",
|
|
"meeting",
|
|
"phonecall",
|
|
"finance",
|
|
"conversationalai",
|
|
"voicemail",
|
|
"video",
|
|
"whisper-tiny",
|
|
"whisper-base",
|
|
"whisper-small",
|
|
"whisper-medium",
|
|
"whisper-large",
|
|
]
|
|
|
|
# served on /v2/listen
|
|
FluxModels = Literal["flux-general-en", "flux-general-multi"]
|
|
|
|
# https://developers.deepgram.com/docs/models-languages-overview
|
|
DeepgramLanguages = Literal[
|
|
"zh",
|
|
"zh-CN",
|
|
"zh-TW",
|
|
"zh-HK",
|
|
"da",
|
|
"nl",
|
|
"en",
|
|
"en-US",
|
|
"en-AU",
|
|
"en-GB",
|
|
"en-NZ",
|
|
"en-IN",
|
|
"fr",
|
|
"fr-CA",
|
|
"de",
|
|
"hi",
|
|
"hi-Latn",
|
|
"id",
|
|
"it",
|
|
"ja",
|
|
"ko",
|
|
"no",
|
|
"pl",
|
|
"pt",
|
|
"pt-BR",
|
|
"ru",
|
|
"es",
|
|
"es-419",
|
|
"es-LATAM",
|
|
"sv",
|
|
"ta",
|
|
"taq",
|
|
"th",
|
|
"tr",
|
|
"uk",
|
|
"multi",
|
|
]
|
|
|
|
# https://developers.deepgram.com/docs/tts-models
|
|
TTSModels = Literal[
|
|
# Aura-2 English
|
|
"aura-2-andromeda-en",
|
|
"aura-2-apollo-en",
|
|
"aura-2-arcas-en",
|
|
"aura-2-aries-en",
|
|
"aura-2-artemis-en",
|
|
"aura-2-asteria-en",
|
|
"aura-2-atlas-en",
|
|
"aura-2-aurora-en",
|
|
"aura-2-callisto-en",
|
|
"aura-2-cetus-en",
|
|
"aura-2-chiron-en",
|
|
"aura-2-columbia-en",
|
|
"aura-2-cordelia-en",
|
|
"aura-2-crina-en",
|
|
"aura-2-draco-en",
|
|
"aura-2-electra-en",
|
|
"aura-2-eos-en",
|
|
"aura-2-harmonia-en",
|
|
"aura-2-helios-en",
|
|
"aura-2-hera-en",
|
|
"aura-2-hermes-en",
|
|
"aura-2-hyperion-en",
|
|
"aura-2-io-en",
|
|
"aura-2-iris-en",
|
|
"aura-2-janus-en",
|
|
"aura-2-juno-en",
|
|
"aura-2-jupiter-en",
|
|
"aura-2-luna-en",
|
|
"aura-2-mars-en",
|
|
"aura-2-minerva-en",
|
|
"aura-2-mira-en",
|
|
"aura-2-neptune-en",
|
|
"aura-2-odysseus-en",
|
|
"aura-2-ophiuchus-en",
|
|
"aura-2-orion-en",
|
|
"aura-2-orpheus-en",
|
|
"aura-2-phoebe-en",
|
|
"aura-2-pluto-en",
|
|
"aura-2-saturn-en",
|
|
"aura-2-selene-en",
|
|
"aura-2-theia-en",
|
|
"aura-2-titan-en",
|
|
"aura-2-triton-en",
|
|
"aura-2-vega-en",
|
|
"aura-2-venus-en",
|
|
"aura-2-zeus-en",
|
|
# Aura-1 English (legacy)
|
|
"aura-asteria-en",
|
|
"aura-luna-en",
|
|
"aura-stella-en",
|
|
"aura-athena-en",
|
|
"aura-hera-en",
|
|
"aura-orion-en",
|
|
"aura-arcas-en",
|
|
"aura-perseus-en",
|
|
"aura-angus-en",
|
|
"aura-orpheus-en",
|
|
"aura-helios-en",
|
|
"aura-zeus-en",
|
|
]
|
|
|
|
# Flux TTS voices, served on the /v2/speak endpoint.
|
|
# https://developers.deepgram.com/docs/flux-tts/overview
|
|
# Model names follow the `flux-{voice}-{language}` format; seeded with the
|
|
# documented example and kept open via `FluxTTSModels | str` so new voices
|
|
# work without a code change.
|
|
FluxTTSModels = Literal["flux-alexis-en"]
|
|
|
|
|
|
class TranscriptionWord(BaseModel):
|
|
word: str = ""
|
|
punctuated_word: str | None = None
|
|
start: float = 0.0
|
|
end: float = 0.0
|
|
confidence: float | None = None
|
|
speaker: int | None = None
|
|
|
|
|
|
class TranscriptionAlternative(BaseModel):
|
|
transcript: str
|
|
confidence: float
|
|
words: list[TranscriptionWord] = Field(default_factory=list[TranscriptionWord])
|
|
languages: list[str] = Field(default_factory=list[str])
|
|
|
|
|
|
class TranscriptionChannel(BaseModel):
|
|
alternatives: list[TranscriptionAlternative] = Field(
|
|
default_factory=list[TranscriptionAlternative]
|
|
)
|
|
detected_language: str = ""
|
|
|
|
|
|
class TranscriptionMetadata(BaseModel):
|
|
request_id: str = ""
|
|
|
|
|
|
class TranscriptionResults(BaseModel):
|
|
channels: list[TranscriptionChannel] = Field(default_factory=list[TranscriptionChannel])
|
|
|
|
|
|
class TranscriptionResponse(BaseModel):
|
|
metadata: TranscriptionMetadata = Field(default_factory=TranscriptionMetadata)
|
|
results: TranscriptionResults = Field(default_factory=TranscriptionResults)
|