The Fish Audio API is a developer interface for ultra-low-latency text-to-speech (TTS), zero-shot voice cloning, and expressive speech synthesis powered by Fish Audio’s open-source and commercial speech models (notably the Fish Speech architecture). Positioned as a fast, cost-effective, and highly customizable alternative to legacy voice APIs, it enables developers to generate natural, emotionally nuanced speech across multiple languages from short text prompts or brief reference audio clips.
What Sets the Fish Audio API Apart
Most traditional TTS engines rely on rigid phoneme pipelines or require minutes of studio-grade recordings to clone a voice. Fish Audio approaches speech synthesis using a dual-autoregressive transformer and
- Zero-Shot & Instant Voice Cloning: Developers can clone a speaker’s timbre, cadence, and accent using just 10 to 30 seconds of clean reference audio, either uploaded dynamically per request or saved as a persistent voice model ID.
- Sub-Second Streaming Latency: Built for conversational AI agents and real-time voice assistants, the API supports HTTP chunked streaming and WebSockets, delivering first-byte audio in roughly 150–300 milliseconds.
- Fine-Grained Prosody & Emotion Control: Inline control tags and reference prompts allow synthesized speech to convey laughter, whispers, excitement, sighs, or dramatic pauses without switching voice models.
- Multilingual & Cross-Lingual Synthesis: The underlying models natively support English, Chinese, Japanese, Korean, French, German, Spanish, and Arabic—and can make a cloned English voice speak fluent Japanese while preserving the original speaker’s vocal identity.
- Open-Weights Ecosystem: Unlike purely closed-box APIs, Fish Audio maintains open-source weights (
fish-speech), allowing teams to prototype on the hosted API and self-host on local GPUs when data sovereignty or scale demands it.
Core API Capabilities & Endpoints
The Fish Audio REST API is organized around three primary workflows: generating speech from text, managing custom voice models, and transcribing audio.
| Endpoint / Feature | Method | Primary Function | Key Parameters |
|---|---|---|---|
/v1/tts |
POST |
Synthesizes text into MP3, WAV, PCM, or Opus audio streams. | text, reference_id, format, mp3_bitrate, latency |
/model |
POST / GET |
Creates, lists, and manages persistent custom voice models from audio samples. | title, voices (audio files), texts (transcripts), visibility |
/v1/asr |
POST |
Automatic speech recognition for transcribing input audio or generating cloning transcripts. | audio, language, ignore_timestamps |
| WebSocket TTS | WSS |
Bidirectional streaming for LLM-to-speech pipelines where text arrives token-by-token. | text chunks, reference_id, chunk_length |
Quickstart: Generating Speech with Python
Fish Audio provides an official Python SDK (fish-audio-sdk) alongside standard REST and cURL compatibility. Below is a complete example demonstrating both standard synthesis using a pre-built voice ID and on-the-fly voice cloning from a local audio file.
import os
from fish_audio_sdk import Session, TTSRequest, ReferenceAudio
# Initialize the client using your Fish Audio API key
session = Session(os.environ["FISH_API_KEY"])
# 1. Generate speech using an existing hosted voice model ID
def synthesize_with_model(text: str, voice_id: str, output_path: str):
request = TTSRequest(
text=text,
reference_id=voice_id,
format="mp3",
mp3_bitrate=128,
latency="balanced" # Options: "normal" or "balanced" (lower latency)
)
with open(output_path, "wb") as f:
for chunk in session.tts(request):
f.write(chunk)
# 2. Zero-shot cloning using a 15-second local reference clip
def clone_and_speak(text: str, sample_path: str, sample_transcript: str, output_path: str):
with open(sample_path, "rb") as audio_file:
reference = ReferenceAudio(
audio=audio_file.read(),
text=sample_transcript
)
request = TTSRequest(
text=text,
references=[reference],
format="wav"
)
with open(output_path, "wb") as f:
for chunk in session.tts(request):
f.write(chunk)
if __name__ == "__main__":
synthesize_with_model(
text="(excited) Welcome back! Today we're building a real-time voice agent.",
voice_id="7f92f8afb8ec43bf81429cc1c9199cb1",
output_path="welcome.mp3"
)
Engineering Best Practices for Production
Integrating generative voice synthesis into live applications requires balancing audio fidelity, latency, and ethical safeguards:
- Stream PCM for Real-Time Agents: When connecting Fish Audio to a streaming Large Language Model (LLM), request raw
pcmoropuschunks over WebSockets rather than waiting for a completemp3file. This eliminates decoding overhead and lets playback start on the very first sentence fragment. - Curate Reference Audio Carefully: For voice cloning, a single 15-second clip recorded in a quiet room with consistent microphone distance outperforms five minutes of noisy, reverberant audio. Always supply an accurate
sample_transcript—mismatched transcripts degrade pronunciation accuracy. - Use Emotion Tags Sparingly: Tags such as
(laughing),(sighing),(whispering), or(sad)work best at clause boundaries. Overloading a single sentence with conflicting tags can cause erratic pitch shifts. - Implement Consent & Watermarking Gates: Because zero-shot cloning can replicate a voice from minimal audio, production apps should enforce explicit speaker consent checks and rate-limit dynamic reference uploads to prevent impersonation abuse.
Common Use Cases
- Conversational AI & Customer Support: Powering responsive, human-sounding phone and web agents that match brand personas without robotic pauses.
- Interactive Gaming & NPCs: Generating dynamic, emotionally reactive dialogue for non-player characters without pre-recording thousands of studio lines.
- Content Localization & Dubbing: Translating podcasts, educational courses, and short-form video into new languages while retaining the original creator’s voice.
- Accessibility & Assisted Communication: Giving individuals with speech impairments personalized synthetic voices built from archived personal recordings.
Leave a Reply