Skip to main content

fishaudio.types.voices

Voice and model management types.

Sample Objects

A sample audio for a voice model. Attributes:
  • title - Title/name of the audio sample
  • text - Transcription of the spoken content in the sample
  • task_id - Unique identifier for the sample task
  • audio - URL or path to the audio file

Author Objects

Voice model author information. Attributes:
  • id - Unique author identifier
  • nickname - Author’s display name
  • avatar - URL to author’s avatar image

Voice Objects

A voice model. Represents a TTS voice that can be used for synthesis. Attributes:
  • id - Unique voice model identifier (use as reference_id in TTS)
  • type - Model type. Options: “svc” (singing voice conversion), “tts” (text-to-speech)
  • title - Voice model title/name
  • description - Detailed description of the voice model
  • cover_image - URL to the voice model’s cover image
  • train_mode - Training mode used. Options: “fast”
  • state - Current model state: “created”, “training”, “trained”, or “failed”
  • tags - List of tags for categorization (e.g., [“male”, “english”, “young”])
  • samples - List of audio samples demonstrating the voice
  • created_at - Timestamp when the model was created
  • updated_at - Timestamp when the model was last updated
  • languages - List of supported language codes (e.g., [“en”, “zh”])
  • visibility - Model visibility. Options: “public”, “private”, “unlist”
  • lock_visibility - Whether visibility setting is locked
  • like_count - Number of likes the model has received
  • mark_count - Number of bookmarks/favorites
  • shared_count - Number of times the model has been shared
  • task_count - Number of times the model has been used for generation
  • liked - Whether the current user has liked this model. Default: False
  • marked - Whether the current user has bookmarked this model. Default: False
  • author - Information about the voice model’s creator

fishaudio.types.account

Account-related types (credits, packages, etc.).

Credits Objects

User’s API credit balance. Attributes:
  • id - Unique credits record identifier
  • user_id - User identifier
  • credit - Current credit balance (decimal for precise accounting)
  • created_at - Timestamp when the credits record was created
  • updated_at - Timestamp when the credits were last updated
  • has_phone_sha256 - Whether the user has a verified phone number. Optional
  • has_free_credit - Whether the user has received free credits. Optional

Package Objects

User’s prepaid package information. Attributes:
  • id - Unique package identifier
  • user_id - User identifier
  • type - Package type identifier
  • total - Total units in the package
  • balance - Remaining units in the package
  • created_at - Timestamp when the package was purchased
  • updated_at - Timestamp when the package was last updated
  • finished_at - Timestamp when the package was fully consumed. None if still active

fishaudio.types.tts

TTS-related types.

ReferenceAudio Objects

Reference audio for voice cloning/style. Attributes:
  • audio - Audio file bytes for the reference sample
  • text - Transcription of what is spoken in the reference audio. Should match exactly what’s spoken and include punctuation for proper prosody.

Prosody Objects

Speech prosody settings (speed and volume). Attributes:
  • speed - Speech speed multiplier. Range: 0.5-2.0. Default: 1.0.
  • Examples - 1.5 = 50% faster, 0.8 = 20% slower
  • volume - Volume adjustment in decibels. Range: -20.0 to 20.0. Default: 0.0 (no change). Positive values increase volume, negative values decrease it.

from_speed_override

Create Prosody with speed override, preserving volume from base. Arguments:
  • speed - Speed value to use
  • base - Base prosody to preserve volume from (if any)
Returns: New Prosody instance with overridden speed

TTSConfig Objects

TTS generation configuration. Reusable configuration for text-to-speech requests. Create once, use multiple times. All parameters have sensible defaults. Attributes:
  • format - Audio output format. Options: “mp3”, “wav”, “pcm”, “opus”. Default: “mp3”
  • sample_rate - Audio sample rate in Hz. If None, uses format-specific default.
  • mp3_bitrate - MP3 bitrate in kbps. Options: 64, 128, 192. Default: 128
  • opus_bitrate - Opus bitrate in kbps. Options: -1000, 24, 32, 48, 64. Default: 32
  • normalize - Whether to normalize/clean the input text. Default: True
  • chunk_length - Characters per generation chunk. Range: 100-300. Default: 200. Lower values = faster initial response, higher values = better quality
  • latency - Generation mode. Options: “normal” (higher quality), “balanced” (faster). Default: “balanced”
  • reference_id - Voice model ID from fish.audio (e.g., “9a9cf47702da476aa4629e2506d4a857”). Find IDs in voice URLs or via voices.list()
  • references - List of reference audio samples for instant voice cloning. Default: []
  • prosody - Speech speed and volume settings. Default: None (uses natural prosody)
  • top_p - Nucleus sampling parameter for token selection. Range: 0.0-1.0. Default: 0.7
  • temperature - Randomness in generation. Range: 0.0-1.0. Default: 0.7. Higher = more varied, lower = more consistent
  • max_new_tokens - Maximum number of tokens to generate. Default: 1024
  • repetition_penalty - Penalty for repeated tokens. Default: 1.2
  • min_chunk_length - Minimum chunk length for generation. Default: 50
  • condition_on_previous_chunks - Whether to condition generation on previous chunks. Default: True
  • early_stop_threshold - Threshold for early stopping. Default: 1.0

TTSRequest Objects

Request parameters for text-to-speech generation. This model is used internally for WebSocket streaming. For the HTTP API, parameters are passed directly to methods. Attributes:
  • text - Text to synthesize into speech
  • chunk_length - Characters per generation chunk. Range: 100-300. Default: 200
  • format - Audio output format. Options: “mp3”, “wav”, “pcm”, “opus”. Default: “mp3”
  • sample_rate - Audio sample rate in Hz. If None, uses format-specific default
  • mp3_bitrate - MP3 bitrate in kbps. Options: 64, 128, 192. Default: 128
  • opus_bitrate - Opus bitrate in kbps. Options: -1000, 24, 32, 48, 64. Default: 32
  • references - List of reference audio samples for voice cloning. Default: []
  • reference_id - Voice model ID for using a specific voice. Default: None
  • normalize - Whether to normalize/clean the input text. Default: True
  • latency - Generation mode. Options: “normal”, “balanced”. Default: “balanced”
  • prosody - Speech speed and volume settings. Default: None
  • top_p - Nucleus sampling for token selection. Range: 0.0-1.0. Default: 0.7
  • temperature - Randomness in generation. Range: 0.0-1.0. Default: 0.7
  • max_new_tokens - Maximum number of tokens to generate. Default: 1024
  • repetition_penalty - Penalty for repeated tokens. Default: 1.2
  • min_chunk_length - Minimum chunk length for generation. Default: 50
  • condition_on_previous_chunks - Whether to condition generation on previous chunks. Default: True
  • early_stop_threshold - Threshold for early stopping. Default: 1.0

StartEvent Objects

WebSocket start event to initiate TTS streaming. Attributes:
  • event - Event type identifier, always “start”
  • request - TTS configuration for the streaming session

TextEvent Objects

WebSocket event to send a text chunk for synthesis. Attributes:
  • event - Event type identifier, always “text”
  • text - Text chunk to synthesize

FlushEvent Objects

WebSocket event to force immediate audio generation from buffered text. Use this to ensure all buffered text is synthesized without waiting for more input. Attributes:
  • event - Event type identifier, always “flush”

CloseEvent Objects

WebSocket event to end the streaming session. Attributes:
  • event - Event type identifier, always “stop”

TTSTimestampSegment Objects

Timing of one piece of text (usually a word) in generated speech. Attributes:
  • text - The text covered by this entry. Punctuation is not included, and languages written without spaces are split per character.
  • start - Start time in seconds
  • end - End time in seconds

TTSAlignment Objects

Timing snapshot for one text chunk. Attributes:
  • segments - Timing entries produced so far, with times measured from the start of the chunk’s audio
  • audio_duration - Seconds of the chunk’s audio rendered so far

TTSTimestampEvent Objects

One event from a text-to-speech stream with timestamps. Audio and timing travel together but are not aligned to each other: audio is the next piece of the audio file, while alignment is the newest timing snapshot for the text chunk chunk_seq. Each snapshot replaces the earlier one for the same chunk. The stream objects do this bookkeeping for you and expose the result as segments. Attributes:
  • audio - Next audio bytes. Join them in arrival order to get the complete audio. May be empty on a closing event that only corrects timings.
  • content - Text of the chunk that alignment describes. Long input is split into several chunks.
  • alignment - Newest timing snapshot for chunk chunk_seq, or None when there is none yet or the API cannot time this text
  • chunk_seq - Index of the text chunk that content and alignment describe
  • chunk_audio_offset_sec - Where that chunk starts in the complete audio, in seconds

segments

This event’s snapshot with times measured from the start of the complete audio.

TTSTimestampResult Objects

Complete audio together with the timing of its text. The API cannot always time the text, for example when it contains no words (only punctuation or a sound tag such as “[sigh]”). The audio is complete in that case too, but segments is empty and duration is None. Parts of a long text can also be missing from segments for the same reason. Attributes:
  • audio - Complete audio as bytes
  • segments - Timing entries (usually words) in speaking order, with times in seconds from the start of audio. Empty when the API returned no timings.
  • duration - Length of audio in seconds as reported by the API, or None when the API did not report it. The API reports it together with the timings, so it is None when the end of the audio has no timings. It is never measured from audio; decode the audio if you need its length in that case.

fishaudio.types.shared

Shared types used across the SDK.

PaginatedResponse Objects

Generic paginated response. Attributes:
  • total - Total number of items across all pages
  • items - List of items on the current page

warn_if_deprecated_model

Emit a deprecation warning if a legacy model is used.

fishaudio.types.asr

ASR (Automatic Speech Recognition) related types.

ASRSegment Objects

A timestamped segment of transcribed text. Attributes:
  • text - The transcribed text for this segment
  • start - Segment start time in seconds
  • end - Segment end time in seconds

SpeakerTurn Objects

A stretch of the transcript spoken by one speaker. Attributes:
  • speaker - Speaker label (e.g., “speaker:0”). Labels identify speakers within one response only
  • text - What the speaker said in this turn, without inline speaker markers
  • start - Turn start time in seconds
  • end - Turn end time in seconds

ASRResponse Objects

Response from speech-to-text transcription. Attributes:
  • text - Complete transcription of the entire audio
  • duration - Total audio duration in seconds
  • segments - List of timestamped text segments. Empty if include_timestamps=False
  • language - Display name of the transcript’s language (e.g., “English”). None if not returned
  • language_code - Language code of the transcript (e.g., “en”): the detected language, or the requested language if none was detected. None if not returned
  • request_id - Identifier of this request; quote it when reporting a problem with the request. None if not returned
  • speaker_turns - Speaker turns in order, with times in seconds. Returned only by models with speaker diarization, and only if include_timestamps=True; empty if no speech was found. None otherwise

duration

Duration in seconds

fishaudio.types.asr_realtime

Types for realtime speech-to-text (/v1/asr/realtime).

ASRTurnDetection Objects

How the server decides that a turn has ended. Fields left as None are not sent: the server uses its default at session start, and keeps the current value in a mid-session configure. Attributes:
  • mode - “auto” (default): the server judges when the user has finished and tells user turns from noise and other voices. “vad”: a turn ends after silence_timeout_ms of silence. “manual”: a turn ends when you send finalize
  • eager - Send eager_end_of_turn events (auto mode only). Server default: False
  • silence_timeout_ms - Silence that ends a turn. auto: default 5000, allowed 3000-60000. vad: default 700, allowed 300-60000. manual: default 60000, allowed 300-60000

ASRResults Objects

Which results the server sends, and what the transcript text contains. Fields left as None are not sent: the server uses its default at session start, and keeps the current value in a mid-session configure. Attributes:
  • drafts - Send live draft events. Server default: False
  • ignore_timestamps - False adds word timings to committed events. Server default: True
  • diarize - Speaker tags such as <|speaker:0|> in the text. Server default: True
  • tag_audio_events - Sound tags such as [laughter] in the text. Server default: True
  • vad_events - Send vad events (voice activity, up to 10 per second). Server default: False
  • eot_events - Send eot_prob events (end-of-turn likelihood). Server default: False

ASRContextItem Objects

One line of conversation given to the server as context. Attributes:
  • role - Who said it: “user” or “assistant”
  • text - What was said (up to 2000 characters)

ASRContext Objects

Conversation context that helps the server recognize names and follow-ups. Attributes:
  • history - Earlier conversation, oldest first (up to 32 items). Only accepted at session start; add lines later with context_add
  • terms - Names, products and jargon to recognize (up to 100 terms of up to 32 characters)

ASRRealtimeConfig Objects

Configuration for a realtime speech-to-text session. Attributes:
  • sample_rate - Sample rate of the audio you send, in Hz: 8000, 12000, 16000, 22050, 24000, 32000, 44100 or 48000. The server converts these rates to 16000, so audio at one of them needs no resampling. Default: 16000
  • turn_detection - Turn detection settings. Default: None (server defaults)
  • results - Result settings. Default: None (server defaults)
  • context - Conversation history and custom vocabulary. Default: None
  • client_reference_id - Your own ID for the session (up to 256 characters). Recorded with the session; not sent back. Default: None

ASRFinalizeEvent Objects

Commit the current turn now (push-to-talk: the button was released). Attributes:
  • type - Message type identifier, always “finalize”

ASRAgentSpeakingEvent Objects

Tell the server whether your voice agent is speaking (auto mode). While the agent speaks, a short acknowledgement from the user produces user_backchannel instead of user_turn_taken. Attributes:
  • type - Message type identifier, always “agent_speaking”
  • speaking - True when you commit to playing a reply; False when its last sample has played or you stop it

ASRContextAddEvent Objects

Add conversation context, typically each line your agent speaks. Attributes:
  • type - Message type identifier, always “context_add”
  • items - Conversation items, oldest first (up to 32)
  • reset_history - First drop the items you added before. Default: False

ASRConfigureEvent Objects

Change settings during the session. Answered by a configured event. Attributes:
  • type - Message type identifier, always “configure”
  • turn_detection - Turn detection changes; omitted fields keep their values
  • results - Result changes; omitted fields keep their values
  • context - Only terms is accepted here; it replaces the list of terms

ASRKeepaliveEvent Objects

Keep an idle session open. Rarely needed: the SDK’s WebSocket pings already count as client activity. Attributes:
  • type - Message type identifier, always “keepalive”

ASRWord Objects

A word of a committed transcript with its position in the audio. Attributes:
  • text - The word
  • start_ms - Where the word starts, in milliseconds of session audio
  • end_ms - Where the word ends, in milliseconds of session audio

ASRSessionStartedEvent Objects

The session is ready; audio is sent after this event. Attributes:
  • type - Event type identifier, always “session_started”
  • seq - Sequence number, increasing by one per server message
  • session_id - The session’s ID
  • request_id - Identifier of this request; quote it when reporting a problem
  • config - The configuration in effect, with defaults filled in
  • limits - Session limits (max_session_ms, max_turn_ms, max_frame_bytes)

ASRSpeechStartEvent Objects

A turn opened on voice activity. In auto mode noise and other voices open turns too: wait for user_turn_taken before treating it as the user’s turn. Attributes:
  • type - Event type identifier, always “speech_start”
  • seq - Sequence number
  • turn_index - The turn that opened, counting from 0
  • audio_ms - Where the turn starts, slightly before the speech

ASRUserTurnTakenEvent Objects

Auto mode: the server judged that the user is taking their turn. For a voice agent that is speaking, this is the signal to stop (barge-in). Attributes:
  • type - Event type identifier, always “user_turn_taken”
  • seq - Sequence number
  • turn_index - The turn the user took
  • audio_ms - Where the server judged that the user took the turn

ASRDraftEvent Objects

Live draft of the open turn (with drafts=True). Not final. Attributes:
  • type - Event type identifier, always “draft”
  • seq - Sequence number
  • turn_index - The open turn
  • text - The whole turn so far. Replaces the previous draft
  • settled_text - The beginning of text that the server is confident will not change. Often empty
  • language - English name of the detected language. None if not identified
  • language_code - ISO 639-1 code of the detected language. None if not identified
  • audio_ms - The audio position the draft covers up to
  • audio_received_ms - Audio received so far
  • audio_processed_ms - Audio processed so far
  • audio_committed_ms - Audio covered by committed turns so far

ASREagerEndOfTurnEvent Objects

The turn has probably ended (auto mode with eager=True). Start preparing your response; a turn_resumed event cancels it. Attributes:
  • type - Event type identifier, always “eager_end_of_turn”
  • seq - Sequence number
  • turn_index - The turn that probably ended
  • text - Exactly what committed will say unless turn_resumed follows. Can be empty
  • language - English name of the detected language. None if not identified
  • language_code - ISO 639-1 code of the detected language. None if not identified
  • audio_ms - The audio position of the signal

ASRTurnResumedEvent Objects

The speaker went on after eager_end_of_turn: discard that text. Attributes:
  • type - Event type identifier, always “turn_resumed”
  • seq - Sequence number
  • turn_index - The turn that resumed

ASRUserBackchannelEvent Objects

Auto mode, while your agent speaks: the user only acknowledged (“mm-hm”). Attributes:
  • type - Event type identifier, always “user_backchannel”
  • seq - Sequence number
  • turn_index - The open turn, or the index the next turn will get
  • audio_ms - Where the acknowledgement is in the audio

ASRCommittedEvent Objects

The final transcript of a turn. Every turn has exactly one. Attributes:
  • type - Event type identifier, always “committed”
  • seq - Sequence number
  • turn_index - The turn that ended
  • text - The final transcript. Can contain speaker tags such as <|speaker:0|> and sound tags such as [laughter]. Can be empty
  • words - Word timings. Only with ignore_timestamps=False; None otherwise
  • language - English name of the detected language. None if not identified
  • language_code - ISO 639-1 code of the detected language. None if not identified
  • audio_start_ms - Where the turn starts in the session audio
  • audio_end_ms - Where the turn ends in the session audio
  • reason - Why the turn ended: “eot”, “finalize”, “silence_timeout”, “max_turn_duration” or “audio_done”. Treat an unknown value like “eot”
  • degraded - True when the final pass failed and the text comes from the last draft
  • user_turn - True for the user’s turn. Decide whether to answer by this field
  • turn_kind - “user”, “backchannel” or “other”
  • audio_received_ms - Audio received so far
  • audio_processed_ms - Audio processed so far
  • audio_committed_ms - Audio covered by committed turns so far

ASRVadEvent Objects

Voice activity (with vad_events=True), up to 10 per second. Attributes:
  • type - Event type identifier, always “vad”
  • seq - Sequence number
  • audio_ms - The audio position of the score
  • score - Voice activity, from 0 to 1

ASREotProbEvent Objects

End-of-turn likelihood for display (with eot_events=True). Attributes:
  • type - Event type identifier, always “eot_prob”
  • seq - Sequence number
  • turn_index - The open turn
  • audio_ms - The audio position of the estimate
  • prob - End-of-turn likelihood, from 0 to 1

ASRConfiguredEvent Objects

The reply to a configure message. Attributes:
  • type - Event type identifier, always “configured”
  • seq - Sequence number
  • ok - False means nothing changed
  • config - The configuration in effect
  • message - Why the change was refused, in English. None when ok is True

ASRProgressEvent Objects

Audio watermarks, sent every 5 seconds while the client sends nothing. Attributes:
  • type - Event type identifier, always “progress”
  • seq - Sequence number
  • audio_received_ms - Audio received so far
  • audio_processed_ms - Audio processed so far
  • audio_committed_ms - Audio covered by committed turns so far

ASRErrorEvent Objects

A recoverable error: the session continues, except after server_restarting, which the server follows by closing the connection (raised as ASRRealtimeError with close code 1012). Other errors that end the session are raised as ASRRealtimeError instead. Attributes:
  • type - Event type identifier, always “error”
  • seq - Sequence number
  • code - HTTP-style status
  • error_type - Machine-readable error type, e.g. “invalid_request”. Match on this
  • message - A short English description, for humans
  • request_id - Identifier of this request; quote it when reporting a problem
  • recoverable - True when the error does not end the session by itself

ASRSessionStats Objects

Totals for a finished session. Attributes:
  • audio_ms - Audio received in the session
  • turns - Every committed turn, user turn or not
  • request_id - Identifier of this request

ASRSessionDoneEvent Objects

The session ended normally. Always the last event. Attributes:
  • type - Event type identifier, always “session_done”
  • seq - Sequence number
  • stats - Totals for the session