Skip to main content
POST
Speech to Text
This BETA endpoint transcribes one audio file per request. Send the audio as multipart/form-data (a file upload) or application/msgpack. Base64-encoded audio in a JSON body is not supported.

Select a model

Send POST https://api.fish.audio/v1/asr with Authorization: Bearer <API_KEY> and a model HTTP header that selects the model. The request is synchronous: the response arrives when the whole file has been transcribed. transcribe-1-pro and transcribe-2-pro are the Pro models. Send model: transcribe-2-pro (or model: transcribe-1-pro) with every request, written exactly, in lowercase. If the header is missing, or its value is not an exact match (for example Transcribe-1-Pro, transcribe-2pro, or transcribe-2), the request is served and billed as transcribe-1, and no error is returned; text_format, verbatim, and keyterms are then ignored. If you expected a Pro model but the transcript has no speaker markers and you did not send diarize=false, check the header. This applies to the API playground on this page too: set its model header to the model you want. The model belongs in the header for both multipart and MessagePack requests; a model field in the request body is ignored. See Limits for recording length and request size. To link the request to your own distributed trace, also send a W3C traceparent header. See Tracing & Performance Analysis.

Request fields

Multipart and MessagePack bodies use the same field names. Multipart values are text; MessagePack values are typed. In multipart forms, send true or false for ignore_timestamps. Any value other than true (case-insensitive), including 1 or an empty value, is read as false and turns timestamps on. In MessagePack, send a boolean; a string or nil returns 400. Speaker-count hints are applied on a best-effort basis: they guide speaker identification on longer recordings and may have no effect on short ones. They cannot be sent with diarize=false. tag_audio_events, diarize, the speaker-count hints, text_format, verbatim, and keyterms are validated strictly:
  • In multipart forms, tag_audio_events and verbatim take true or false, diarize takes auto, true, or false, and text_format takes written or spoken, in any letter case. Speaker counts take digits only. Send each of these fields at most once. keyterms is the exception: send it once per term.
  • In MessagePack, send tag_audio_events and verbatim as booleans, diarize as a boolean or one of the lowercase strings auto, true, or false, text_format as the string written or spoken, speaker counts as integers, not floats or strings, and keyterms as an array of strings. nil means the default; for keyterms, nil and an empty array mean no key terms.
  • Any other value, a repeated multipart field, or a conflicting combination returns 400 with code invalid_parameter. So does a key term that breaks the key term rules.
text_format, verbatim, and keyterms apply to transcribe-2-pro only. transcribe-1-pro ignores them. If you use transcribe-1: send audio, language, and ignore_timestamps. The other fields apply to the Pro models; send them only with model: transcribe-1-pro or model: transcribe-2-pro.

Examples

This request returns word-level segments and speaker_turns. For a two-person interview, you can add a speaker-count hint, and remove emotion and vocal-event cues from the transcript:
With transcribe-2-pro, you can also send a language hint and list key terms, one keyterms field per term:
--form-string sends each term as plain text, even one that starts with @, which --form would read as a file to upload. Let your HTTP client set the multipart Content-Type and boundary. For MessagePack, set Content-Type: application/msgpack and encode audio as binary bytes. See the Speech to Text guide for an example.

Text format

With transcribe-2-pro, text_format changes how the model writes numbers, dates, times, and amounts, for the whole recording. written (the default) writes them in digits and symbols, such as 3:30 or 20%; in Chinese transcripts, numbers are usually Arabic digits. spoken writes them in words, as they were said, such as twenty-five dollars. spoken is not always followed when the request also has keyterms: numbers, dates, and amounts can then come back in digits and symbols, as with written. If you need spoken numbers, send the request without key terms.

Verbatim

With transcribe-2-pro, verbatim controls filler words and disfluencies, for the whole recording. true (the default) keeps filler words, stutters, repetitions, and false starts. false leaves out filler sounds, stutters, accidental repetitions, and short false starts. It only removes words, and never rewords or replaces them: meaningful words stay, and so does a short reply such as Mm-hmm. The model decides what counts as a filler or a false start, so it can occasionally leave one in or remove a short word that was meant.

Key terms

With transcribe-2-pro, send keyterms to list words or short phrases that may be spoken in the recording, such as names, products, and technical terms, so the transcript spells them as you list them. List only terms that are likely to occur: a listed term that is never said can occasionally appear in the transcript. Key terms have been tested on short Chinese, Japanese, and English clips.
  • Encoding: in multipart forms, repeat the keyterms field once per term. In MessagePack, send an array of strings.
  • Count: at most 128 terms per request, repeated terms included.
  • Length: each term at most 50 characters and 8 words, counted after leading and trailing whitespace is removed and each run of whitespace inside it is read as one space. Words are separated by spaces, so a Chinese or Japanese term without spaces is one word. An empty term is refused.
  • Characters: a term cannot contain an ASCII comma (,), any of \ < > [ ] { }, or control and invisible formatting characters, such as tabs, line breaks, or zero-width spaces. The zero-width non-joiner and joiner (U+200C, U+200D) and full-width punctuation such as , and 、 are accepted.
  • Reserved starts: a term cannot start with style:, format:, verbatim:, tags:, language hint:, or glossary:, in any letter case.
  • Duplicates: a term listed twice is used once. Two terms that differ only in letter case or character width, such as ABC and ABC, are refused.
  • Total size: all the terms together must fit in the model’s limit of 1024 tokens. Long Chinese or Japanese terms reach it well before 128 terms, at about 32 to 37 terms of 32 characters each, and so can a few long terms in rare scripts. The error message then says the terms are too long in total for the 1024-token limit and gives the list’s token count; send fewer or shorter terms.
A term that breaks a rule returns 400 with code invalid_parameter. The message names the rule and the term’s position in the request, such as keyterms[3], counted from 0, but never the term itself. Key terms do not change the price. With key terms, text_format=spoken is not always followed; see Text format.

Read the response

A successful response (HTTP 200) is a JSON object: A field that is not returned is absent from the JSON, never null. Do not depend on the order of keys in the JSON. If you use transcribe-1: rely on text, duration, segments, language, and language_code. Speaker markers, speaker_turns, and request_id are features of the Pro models.
Both SDKs select the model through the model header. In Python, pass model="transcribe-2-pro" to asr.transcribe() (fish-audio-sdk 1.5.0 or later; on earlier versions, pass request_options=RequestOptions(additional_headers={"model": "transcribe-2-pro"})). In JavaScript, pass model: "transcribe-2-pro" in the request to speechToText.convert() (fish-audio 0.2.0 or later; on 0.1.0, pass { headers: { model: "transcribe-2-pro" } } as the second argument). Select transcribe-1-pro the same way. fish-audio-sdk 1.9.0 or later and fish-audio 0.6.0 or later also send tag_audio_events, diarize, the speaker-count hints, text_format, verbatim, and keyterms, under the same names; with earlier versions, call the API directly, as in the examples above. The Python SDK returns the fields listed above (fish-audio-sdk 1.4.0 or later; earlier versions keep only text, duration, and segments). The JavaScript SDK returns the whole response body; its STTResponse type declares text, duration, segments, request_id (0.4.0 or later), and speaker_turns (0.6.0 or later).

Multi-speaker response format

The Pro models mark speaker changes inside the text string with <|speaker:N|> markers. The label N identifies the speaker for the text that follows, up to the next marker. A repeated label means that speaker is speaking again.
  • Markers usually have a space on each side (<|speaker:0|> 你好。 <|speaker:1|> ...). Do not depend on exact spacing.
  • Any text before the first marker belongs to the first turn.
  • Unless you send diarize=false, which removes the markers, a transcript with no marker comes from a single speaker; treat it as speaker 0.
  • Labels identify speakers within one response only. They are not names, and the same label in two requests is not the same person. Send a whole conversation as one file.
This illustrative response has two speakers and three turns. With ignore_timestamps=true (the default), timestamps are skipped and speaker_turns is absent:
Read this as speaker 0 saying 你好。, speaker 1 saying [高兴]很开心认识你。, and speaker 0 saying 我也是。. The [高兴] cue describes the delivery of speaker 1’s speech. There is no separate emotion field; the cues are part of the text.

Speaker turns

With ignore_timestamps=false, the Pro models also return the turns as a structured speaker_turns array, unless you send diarize=false. When you request timestamps, prefer speaker_turns over parsing text.
  • speaker_turns lists the turns in the order they occur, and is [] when no speech was found. Each turn is { "speaker": "speaker:N", "text": "...", "start": <seconds>, "end": <seconds> }.
  • speaker is the string speaker:N, where N matches the <|speaker:N|> marker in text. Like the markers, labels identify speakers within one response only.
  • text is that turn’s speech without speaker markers. It keeps emotion and vocal-event cues unless tag_audio_events=false.
  • start and end come from the word timestamps. If word timing is unavailable (segments is empty), turn times are approximate and can cover the whole recording.
  • Consecutive turns can have the same speaker. Do not assume turns are contiguous or non-overlapping.
This illustrative response is the same conversation with ignore_timestamps=false:
See the Speech to Text guide for parsing examples.

Segments

A segment is usually one word; in Chinese and Japanese it is usually one character, or a few. Segment text has no punctuation and no speaker markers or cues, and can be normalized (for example 35 for 3.5), so it does not always match text character for character. A segment can have start equal to end. Segments are not speaker turns and carry no speaker ID.

Language

language is optional. Responses report one language: for recordings that switch languages, language and language_code do not list every language spoken. With transcribe-1-pro:
  • The language is detected automatically whether or not you send a hint, and a hint does not force the transcript into that language.
  • Use a lowercase ISO 639-1 code such as en, zh, or ja.
  • If the language cannot be determined (for example, very short audio), language_code reports your hint, which is not checked against the audio, and language may be absent.
With transcribe-2-pro:
  • The hint is passed to the model and guides the transcription. Send it when you know the language of the recording. Without a hint, the response language is detected from the transcript, and for some languages it can be missing or name a related language, such as Hindi for Marathi.
  • The hint can be an ISO 639-1 or ISO 639-3 code, an English language name, or a locale such as pt-BR, in any letter case. A hint the model does not recognize, such as auto, is ignored: the model transcribes without a hint, the response language is detected as with transcribe-1-pro, and no error is returned.
  • When the model recognizes the hint, language and language_code report the hint’s language, for example Portuguese and pt for pt-BR, if the transcript agrees with it: no language is detected in the transcript, the language detected is the hint’s, or, for a language that detection cannot identify, the transcript is mostly in a script that language is written in. Otherwise they report the detected language: Chinese speech sent with language=ja returns Chinese and zh.
  • For bs, hr, and sr, language is Bosnian/Croatian/Serbian and language_code is the code you sent.
  • Send the language that is actually spoken. A wrong hint can change the transcript, for example the script it is written in, and a wrong hint in the same script as the speech is not always caught: English speech sent with language=az can return Azerbaijani.

Limits

  • Audio length: up to 60 minutes per request with either Pro model. Longer audio returns 400 with code audio_too_long.
  • Request size: for long recordings, send compressed audio such as MP3, Opus, or AAC. An hour of 128 kbps MP3 is about 55 MiB. A request that is too large returns 413.
  • One conversation per request: send the whole recording in one request. Timestamps and speaker labels then cover the whole recording. Do not split a conversation, because labels are consistent only within one response.
If you use transcribe-1: it is designed for short recordings; for recordings longer than a few minutes, use transcribe-2-pro. It accepts up to 50 MiB per request; keep MP3 and Opus files under 25 MiB. A request that exceeds the size limit returns 413 or 400. A long request can fail with 503 if it exceeds the processing-time limit. Retry, and if it keeps failing, use transcribe-1-pro or split the audio.

Processing time and timeouts

  • Processing time grows with the length of the recording. Long recordings can take several minutes on either Pro model.
  • Set your HTTP client’s timeout accordingly. The official SDKs’ default timeout can be too short for long recordings, and many HTTP libraries default to even less (httpx defaults to 5 seconds). For long recordings, use a generous timeout, for example 15 minutes: httpx.Timeout(900.0, connect=10.0) with httpx, RequestOptions(timeout=900) with the Python SDK, or { timeoutInSeconds: 900 } with the JavaScript SDK.
  • In Node.js, the built-in fetch, which the JavaScript SDK uses, also stops waiting for a response after 5 minutes, even if you set a longer timeout. To wait longer, call setGlobalDispatcher(new Agent({ headersTimeout: 900_000, bodyTimeout: 900_000 })) from the undici package once at startup. See Processing time and timeouts.
  • If a long request fails with a 5xx error or the connection drops, retry it.
  • Each request holds one of your account’s concurrent request slots until its response is returned.

Supported audio formats

  • The Pro models accept WAV, MP3, AAC (including M4A/MP4), FLAC, Ogg (Opus or Vorbis), WebM/Matroska, and MOV, including browser recordings. For a video file, they use the first audio track. Send the original file bytes; no conversion is needed.
  • Not supported: AIFF, CAF, WMA, AMR, AC-3, and raw (headerless) PCM. These return 400.
If you use transcribe-1: it accepts WAV, MP3, AAC (including M4A/MP4), FLAC, and Ogg (Opus or Vorbis). Browser WebM recordings (for example, from MediaRecorder) may not be accepted; convert them to Ogg/Opus, MP3, or WAV first.

Errors

Error responses have one of these shapes:
  • Pro model errors, from transcribe-1-pro and transcribe-2-pro, are JSON with status, message, code, and request_id. Branch on code, not on message.
  • Platform errors, such as authentication, credit, and concurrency errors, are returned before the request reaches a model. They are JSON with exactly status and message.
  • Errors from the network edge in front of the API, such as some 413 and 5xx responses, may not have a JSON body. Handle them by HTTP status.
This illustrative Pro model error body shows the shape:
  • A dash means the error has no code; a 503 without a code also means the service is temporarily unavailable.
  • New code values may be added; handle unknown codes by HTTP status.
  • Retry 429 and 5xx responses with exponential backoff. Do not retry other 4xx responses; change the request first.
  • Requests that return an error response are not billed.
  • With the Python SDK, the raw error body is in the exception’s body attribute; parse it with json.loads to read code and request_id.
If you use transcribe-1: its errors are JSON with status and message. Rely only on these two fields and on the HTTP status. See Errors for retry and SDK exception examples.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

model
enum<string>
default:transcribe-1

Specify which speech-to-text model to use.

Available options:
transcribe-1,
transcribe-1-pro,
transcribe-2-pro

Body

audio
file
required

Audio file to be converted to text

language
string | null

Optional hint. The language is auto-detected regardless; the detected language is returned as language_code.

ignore_timestamps
boolean
default:true

Whether to return precise timestamps in the text, this will increase the latency in audio shorter than 30 seconds

Response

Request fulfilled, document follows

text
string
required
duration
number
required

Duration of the audio in seconds

segments
ASRSegment · object[]
required
language_code
string | null

Detected language as an ISO 639-1 code (e.g. en, ja). Omitted if no language is detected.

language
string | null

Detected language name (e.g. English). For display only; use language_code in code.