Agent Framework plugin for AssemblyAI
Actively maintained. Last release 5 days ago, commits in 26 of the last 26 weeks. A safe choice.
pip install livekit-plugins-assemblyaiAssemblyAI plugin for LiveKit Agents
Support for Streaming Speech-to-Text and Streaming Text-to-Speech from AssemblyAI.
More information is available in the docs for the STT integration and for AssemblyAI's Streaming TTS.
Installation
pip install livekit-plugins-assemblyai
Pre-requisites
You'll need to specify an AssemblyAI API Key. It can be set as environment variable: ASSEMBLYAI_API_KEY.
Usage
from livekit.agents import AgentSession, TurnHandlingOptions
from livekit.plugins import assemblyai
session = AgentSession(
stt=assemblyai.STT(model="assemblyai-stt-3-7-realtime-agent", mode="balanced"),
tts=assemblyai.TTS(
model="assemblyai-tts-1",
voice="49c443a4-8a1d-5f7e-b70b-98bdbd9823c3", # Audrey
),
# let AssemblyAI decide when the user has finished speaking
turn_handling=TurnHandlingOptions(turn_detection="stt"),
# use the TTS word timings for the transcript and for what an interrupted reply said
use_tts_aligned_transcript=True,
# ... llm, vad, etc.
)
Speech-to-text
assemblyai.STT streams AssemblyAI-STT-3.7-Realtime-Agent by default (model). Useful options:
mode:"min_latency","balanced","max_accuracy"or"manual"(see below).language_codes: steer transcription toward one or more expected languages ("es"or["en", "es"]).prompt: context about the audio, such as its domain or scenario, to help recognize likely vocabulary (up to 1,750 characters).keyterms_prompt: names and terms the model should get right.
Manual mode
To let a LiveKit turn detector decide when the user is done, set mode="manual". AssemblyAI then
doesn't end turns on short pauses. When LiveKit ends the turn, the plugin sends AssemblyAI a
ForceEndpoint and gets that turn's final transcript back right away.
from livekit.agents import AgentSession, TurnHandlingOptions, inference
from livekit.plugins import assemblyai
session = AgentSession(
stt=assemblyai.STT(model="assemblyai-stt-3-7-realtime-agent", mode="manual"),
vad=inference.VAD(),
turn_handling=TurnHandlingOptions(turn_detection=inference.TurnDetector()),
# ... llm, tts, etc.
)