Build real-time voice AI agents with Fish Audio and LiveKit
LiveKit Agents is an open source framework for building real-time voice and multimodal AI agents. It handles streaming audio pipelines, turn detection, interruptions, and LLM orchestration so you can focus on your agent’s behavior.Fish Audio integrates with LiveKit through the fishaudio plugin, providing text-to-speech synthesis with support for both chunked and real-time WebSocket streaming modes.
Python 3.10 or higher (livekit-plugins-fishaudio requires it)
Installation
Install LiveKit Agents with Fish Audio support:
pip install "livekit-agents[fishaudio]"
Configuration
Set your Fish Audio API key as an environment variable:
export FISH_API_KEY=your_api_key_here
Basic usage
Add Fish Audio TTS to your LiveKit agent:
from livekit.plugins.fishaudio import TTStts = TTS( voice_id="your_voice_model_id", # Optional: use a specific voice model="s3-pro", sample_rate=24000, latency_mode="balanced")
Key parameters
Parameter
Description
api_key
Your Fish Audio API key (or use FISH_API_KEY env var)
model
TTS model/backend to use (default: s3-pro in plugin releases after 1.9.0, s2.1-pro in 1.9.0 and earlier)
voice_id
Voice model ID from the Fish Audio library (the API calls it reference_id)
output_format
Audio format: pcm, mp3, wav, or opus (default: wav)
sample_rate
Audio sample rate in Hz (default: 24000 for wav and pcm, 32000 for mp3, 48000 for opus)
num_channels
Number of audio channels (default: 1)
base_url
Custom API endpoint (default: https://api.fish.audio)