S2.1 Pro
import { experimental_generateSpeech as generateSpeech } from 'ai';import { gateway } from '@ai-sdk/gateway';import { writeFile } from 'node:fs/promises';
const result = await generateSpeech({ model: gateway.speechModel('fish-audio/s2.1-pro'), text: 'Hello from the Vercel AI Gateway!', // Browse voices at https://fish.audio/app/discovery // Open a voice, then use "Copy Model Id" in its "..." menu. voice: '933563129e564b19a115bedd57b7406a',});
await writeFile('speech.mp3', result.audio.uint8Array);Copy link to headingAbout S2.1 Pro
S2.1 Pro is Fish Audio's recommended production text-to-speech model and an improved version of S2 Pro, with better quality, latency, and throughput across 83 languages.
Prosody control is the distinguishing feature. You write direction inline in square brackets, and the model interprets it as description rather than matching against a fixed vocabulary, so [whispers sweetly] and [laughing nervously] both work without either being a predefined tag. Thousands of distinct tags are recognised, and phrasing outside that set still lands because the model learned the mapping from description to acoustics rather than from a lookup table.
Multi-speaker dialogue runs in a single request. You write both sides of a conversation in one text input, tag each turn with a speaker index, and get back one audio file with both voices rendered. Two speakers are supported per request.
In head-to-head listening comparisons against S2 Pro, S2.1 Pro was preferred in roughly three of every five judgements.
Integration uses the AI SDK's speech generation function.