|
| 1 | +--- |
| 2 | +title: "LiveKit" |
| 3 | +description: "Build real-time voice AI agents with Fish Audio and LiveKit" |
| 4 | +icon: "/images/livekit-logo.jpeg" |
| 5 | +--- |
| 6 | + |
| 7 | +[LiveKit Agents](https://github.com/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. |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- A [Fish Audio account](https://fish.audio) with an API key |
| 14 | +- Python 3.9 or higher |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +Install LiveKit Agents with Fish Audio support: |
| 19 | + |
| 20 | +```bash |
| 21 | +pip install "livekit-agents[fishaudio]" |
| 22 | +``` |
| 23 | + |
| 24 | +## Configuration |
| 25 | + |
| 26 | +Set your Fish Audio API key as an environment variable: |
| 27 | + |
| 28 | +```bash |
| 29 | +export FISH_API_KEY=your_api_key_here |
| 30 | +``` |
| 31 | + |
| 32 | +## Basic usage |
| 33 | + |
| 34 | +Add Fish Audio TTS to your LiveKit agent: |
| 35 | + |
| 36 | +```python |
| 37 | +from livekit.plugins.fishaudio import TTS |
| 38 | + |
| 39 | +tts = TTS( |
| 40 | + reference_id="your_voice_model_id", # Optional: use a specific voice |
| 41 | + model="s1", |
| 42 | + sample_rate=24000, |
| 43 | + latency_mode="balanced" |
| 44 | +) |
| 45 | +``` |
| 46 | + |
| 47 | +### Key parameters |
| 48 | + |
| 49 | +| Parameter | Description | |
| 50 | +|-----------|-------------| |
| 51 | +| `api_key` | Your Fish Audio API key (or use `FISH_API_KEY` env var) | |
| 52 | +| `model` | TTS model/backend to use (default: `s1`) | |
| 53 | +| `reference_id` | Voice model ID from the [Fish Audio library](https://fish.audio/discover) | |
| 54 | +| `output_format` | Audio format: `pcm`, `mp3`, `wav`, or `opus` (default: `pcm`) | |
| 55 | +| `sample_rate` | Audio sample rate in Hz (default: `24000`) | |
| 56 | +| `num_channels` | Number of audio channels (default: `1`) | |
| 57 | +| `base_url` | Custom API endpoint (default: `https://api.fish.audio`) | |
| 58 | +| `latency_mode` | `normal` (~500ms) or `balanced` (~300ms, default) | |
| 59 | + |
| 60 | +### Streaming modes |
| 61 | + |
| 62 | +The plugin supports two synthesis modes: |
| 63 | + |
| 64 | +```python |
| 65 | +# Chunked (non-streaming) synthesis |
| 66 | +stream = tts.synthesize("Hello, world!") |
| 67 | + |
| 68 | +# Real-time WebSocket streaming |
| 69 | +stream = tts.stream() |
| 70 | +``` |
| 71 | + |
| 72 | +## Resources |
| 73 | + |
| 74 | +- [LiveKit Agents Documentation](https://docs.livekit.io/agents/) |
| 75 | +- [LiveKit GitHub](https://github.com/livekit/agents) |
| 76 | +- [Fish Audio Plugin Reference](https://docs.livekit.io/reference/python/v1/livekit/plugins/fishaudio/index.html) |
| 77 | +- [Fish Audio Voice Library](https://fish.audio/discover) |
0 commit comments