fishaudio.resources.voices
Voice management namespace client. Install the Python SDK first:pip install fish-audio-sdk.
VoicesClient Objects
list
page_size- Number of results per pagepage_number- Page number (1-indexed)title- Filter by titletags- Filter by tags (single tag or list)self_only- Only return user’s own voicesauthor_id- Filter by author IDlanguage- Filter by language(s)title_language- Filter by title language(s)sort_by- Sort field (“task_count” or “created_at”)request_options- Request-level overrides
get
voice_id- Voice model IDrequest_options- Request-level overrides
create
title- Voice model namevoices- List of audio file bytes for trainingdescription- Voice descriptiontexts- Transcripts for voice samplestags- Tags for categorizationcover_image- Cover image bytesvisibility- Visibility setting (public, unlist, private)train_mode- Training mode (currently only “fast” supported)enhance_audio_quality- Whether to enhance audio qualityrequest_options- Request-level overrides
update
voice_id- Voice model IDtitle- New titledescription- New descriptioncover_image- New cover image bytesvisibility- New visibility settingtags- New tagsrequest_options- Request-level overrides
delete
voice_id- Voice model IDrequest_options- Request-level overrides
AsyncVoicesClient Objects
list
get
create
update
delete
fishaudio.resources.account
Account namespace client for billing and credits.AccountClient Objects
get_credits
check_free_credit- Whether to check free credit availabilityrequest_options- Request-level overrides
get_package
request_options- Request-level overrides
AsyncAccountClient Objects
get_credits
check_free_credit- Whether to check free credit availabilityrequest_options- Request-level overrides
get_package
request_options- Request-level overrides
fishaudio.resources.tts
TTS (Text-to-Speech) namespace client.TTSClient Objects
stream
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided)latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
convert
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided)latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
stream_with_timestamps
stream.segments.
Arguments:
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided). “opus” is the best fit for playing audio while it streams; “wav” and “pcm” are uncompressed, which keeps sample positions exact.latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
convert_with_timestamps
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided). “opus” is the best fit for playing audio while it streams; “wav” and “pcm” are uncompressed, which keeps sample positions exact.latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
segments is empty and duration is None.
Example:
stream_websocket
text_stream- Iterator of text chunks to streamreference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided)latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to usemax_workers- ThreadPoolExecutor workers for concurrent senderws_options- WebSocket connection options for configuring timeouts, message size limits, etc. Useful for long-running generations that may exceed default timeout values. See WebSocketOptions class for available parameters.
AsyncTTSClient Objects
stream
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided)latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
convert
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided)latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
stream_with_timestamps
stream.segments.
Arguments:
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided). “opus” is the best fit for playing audio while it streams; “wav” and “pcm” are uncompressed, which keeps sample positions exact.latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
convert_with_timestamps
text- Text to synthesizereference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided). “opus” is the best fit for playing audio while it streams; “wav” and “pcm” are uncompressed, which keeps sample positions exact.latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to userequest_options- Request-level overrides
segments is empty and duration is None.
Example:
stream_websocket
text_stream- Async iterator of text chunks to streamreference_id- Voice reference ID (overrides config.reference_id if provided)references- Reference audio samples (overrides config.references if provided)format- Audio format - “mp3”, “wav”, “pcm”, or “opus” (overrides config.format if provided)latency- Latency mode - “normal” or “balanced” (overrides config.latency if provided)speed- Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)config- TTS configuration (audio settings, voice, model parameters)model- TTS model to usews_options- WebSocket connection options for configuring timeouts, message size limits, etc. Useful for long-running generations that may exceed default timeout values. See WebSocketOptions class for available parameters.
fishaudio.resources.realtime
Real-time WebSocket streaming helpers.iter_websocket_audio
ws- WebSocket connection from httpx_ws.connect_ws
WebSocketError- On disconnect or error finish event
aiter_websocket_audio
ws- WebSocket connection from httpx_ws.aconnect_ws
WebSocketError- On disconnect or error finish event
fishaudio.resources.asr
ASR (Automatic Speech Recognition) namespace client.ASRClient Objects
transcribe
audio- Audio file byteslanguage- Language code (e.g., “en”, “zh”). Auto-detected if not provided.include_timestamps- Whether to include timestamp information for segments (and speaker turns, on models that return them)model- ASR model, e.g. “transcribe-1-pro” (recommended). Sent as themodelheader and takes precedence over one in request_options. If not provided and request_options sets nomodelheader, the request runs on the API’s default model, transcribe-1request_options- Request-level overrides
stream_websocket
<|speaker:0|> Hello., and can contain sound tags such as [laughter].
Pass diarize=False for text without speaker tags; sound tags are turned off
with config=ASRRealtimeConfig(results=ASRResults(tag_audio_events=False)).
Arguments:
audio_stream- Iterator of raw audio chunks: 16-bit little-endian mono PCM, ideally 20-40 ms each, sent as you capture them. It can also yield control messages (e.g. ASRFinalizeEvent()), which are sent at that position in the audiosample_rate- Sample rate of the audio in Hz: 8000, 12000, 16000, 22050, 24000, 32000, 44100 or 48000 (overrides config.sample_rate if provided)turn_detection- When a turn ends - “auto” (the server judges that the user has finished), “vad” (after a fixed silence) or “manual” (when you send finalize) (overrides config.turn_detection.mode if provided)eager- Send eager_end_of_turn events in auto mode (overrides config.turn_detection.eager if provided)drafts- Send live draft events (overrides config.results.drafts if provided)diarize- Speaker tags such as<|speaker:0|>in the transcript text. The server adds them by default; pass False for text without speaker tags (overrides config.results.diarize if provided)terms- Names, products and jargon to recognize (overrides config.context.terms if provided)config- Session configuration (audio, turn detection, results, context)model- Realtime speech-to-text modelws_options- WebSocket connection options for configuring timeouts, message size limits, etc. See WebSocketOptions class for available parameters.
ASRRealtimeStream- an iterator of typed events (check event.type), with methods to send control messages during the session: finalize(), agent_speaking(), add_context() and configure()
ASRRealtimeError- If the server reports an error that ends the session, or closes the connection abnormally (see error_type and close_code)APIError- If the connection is refused (e.g. AuthenticationError for 401)WebSocketError- If the connection is lost
AsyncASRClient Objects
transcribe
audio- Audio file byteslanguage- Language code (e.g., “en”, “zh”). Auto-detected if not provided.include_timestamps- Whether to include timestamp information for segments (and speaker turns, on models that return them)model- ASR model, e.g. “transcribe-1-pro” (recommended). Sent as themodelheader and takes precedence over one in request_options. If not provided and request_options sets nomodelheader, the request runs on the API’s default model, transcribe-1request_options- Request-level overrides
stream_websocket
<|speaker:0|> Hello., and can contain sound tags such as [laughter].
Pass diarize=False for text without speaker tags; sound tags are turned off
with config=ASRRealtimeConfig(results=ASRResults(tag_audio_events=False)).
Arguments:
audio_stream- Async iterator of raw audio chunks: 16-bit little-endian mono PCM, ideally 20-40 ms each, sent as you capture them. It can also yield control messages (e.g. ASRFinalizeEvent()), which are sent at that position in the audiosample_rate- Sample rate of the audio in Hz: 8000, 12000, 16000, 22050, 24000, 32000, 44100 or 48000 (overrides config.sample_rate if provided)turn_detection- When a turn ends - “auto” (the server judges that the user has finished), “vad” (after a fixed silence) or “manual” (when you send finalize) (overrides config.turn_detection.mode if provided)eager- Send eager_end_of_turn events in auto mode (overrides config.turn_detection.eager if provided)drafts- Send live draft events (overrides config.results.drafts if provided)diarize- Speaker tags such as<|speaker:0|>in the transcript text. The server adds them by default; pass False for text without speaker tags (overrides config.results.diarize if provided)terms- Names, products and jargon to recognize (overrides config.context.terms if provided)config- Session configuration (audio, turn detection, results, context)model- Realtime speech-to-text modelws_options- WebSocket connection options for configuring timeouts, message size limits, etc. See WebSocketOptions class for available parameters.
AsyncASRRealtimeStream- an async iterator of typed events (check event.type), with methods to send control messages during the session: finalize(), agent_speaking(), add_context() and configure()
ASRRealtimeError- If the server reports an error that ends the session, or closes the connection abnormally (see error_type and close_code)APIError- If the connection is refused (e.g. AuthenticationError for 401)WebSocketError- If the connection is lost
fishaudio.resources.asr_realtime
Realtime speech-to-text sessions over WebSocket.encode_config
config message that opens a session.
encode_message
decode_event
ASRRealtimeStream Objects
close())
if you keep a reference to it after leaving the loop.
The audio stream is read on a background thread. When the session ends
before the audio does, that thread stops as soon as the audio stream yields
its next chunk, and closes the stream if it is a generator. The SDK cannot
interrupt an audio stream that is blocked waiting for audio (for example a
microphone read with no timeout): make your audio source end, or yield
regularly, so the thread can exit.
Closing does not wait for a server that has stopped reading: a write that
is still pending after half a second is interrupted by cutting the
connection, without a close frame.
Read the events from one thread at a time.
The control methods send a message at the current position in the audio
stream; they can be called from any thread once session_started has
been received.
close
send
WebSocketError- If the session is not open (not started yet, or closed)
finalize
agent_speaking
add_context
configure
keepalive
AsyncASRRealtimeStream Objects
async for for the server’s events. The connection opens
on the first iteration and closes when the session ends, when an error is
raised, or when you leave the loop early. Use it as an async context manager
(or call aclose()) if you keep a reference to it after leaving the loop.
Closing cancels the task that reads the audio stream and closes the stream
if it is an async generator. Up to 256 events are buffered for a consumer
that reads slowly; beyond that the session stops reading from the server
until the consumer catches up.
Read the events from one task at a time: a read started while another is
waiting raises RuntimeError. A read that was cancelled (for example by
asyncio.wait_for) loses nothing; just read again.
The control methods send a message at the current position in the audio
stream; they can be awaited once session_started has been received.
Keep reading: when you stop, the SDK buffers a few hundred events and then
stops reading from the connection, which also stops it answering keepalive
pings. A consumer that stays stalled past the keepalive timeout (20 s by
default, see ws_options) while events keep arriving loses the connection.
aclose
send
WebSocketError- If the session is not open (not started yet, or closed)

