Audio input that streams and resamples external meeting audio for STT in LiveKit agents.
# 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.
"""Meeting audio ingestion and relay streaming for external video meetings."""
from __future__ import annotations
import asyncio
import logging
import struct
from collections.abc import Callable
import aiohttp
import numpy as np
from livekit import rtc
from livekit.agents.voice.io import AudioInput
logger = logging.getLogger(__name__)
_HEADER = struct.Struct("<IB")
_DEFAULT_STT_RATE = 16000
_STT_CHANNELS = 1
_INITIAL_RECONNECT_DELAY_S = 1.0
_MAX_RECONNECT_DELAY_S = 30.0
def _deserialize_frame(payload: bytes) -> rtc.AudioFrame | None:
if len(payload) < _HEADER.size:
return
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key