diff --git a/.mintlify/skills/fish-audio-sdk/SKILL.md b/.mintlify/skills/fish-audio-sdk/SKILL.md index b54cb805..957a8ffe 100644 --- a/.mintlify/skills/fish-audio-sdk/SKILL.md +++ b/.mintlify/skills/fish-audio-sdk/SKILL.md @@ -83,7 +83,7 @@ const audio = await client.textToSpeech.convert( | Install, auth, playback deps, verify a key | [references/installation.md](references/installation.md) | | Text-to-Speech (convert, stream, formats, prosody, model select) | [references/text-to-speech.md](references/text-to-speech.md) | | Voice cloning (instant references + persistent voice models) | [references/voice-cloning.md](references/voice-cloning.md) | -| Speech-to-Text (models, timestamps, fields the SDK drops, realtime in JS) | [references/speech-to-text.md](references/speech-to-text.md) | +| Speech-to-Text (models, timestamps, response fields by SDK version, realtime in JS) | [references/speech-to-text.md](references/speech-to-text.md) | | Realtime WebSocket TTS (stream text → audio) | [references/websocket.md](references/websocket.md) | | Errors, retries, and timeouts (the **real** exception types) | [references/errors.md](references/errors.md) | @@ -125,4 +125,4 @@ The two SDKs do **not** use the same names. Use this map when porting code betwe - Python `latency` accepts only **`"normal"` or `"balanced"`** (default `"balanced"`); there is no `"low"`. - The Python client has **no `max_retries`** and does **not** auto-retry; the JS client **does** auto-retry (configurable via per-call `requestOptions.maxRetries`). See [errors](references/errors.md). - Python defines a `ValidationError` class but **never raises it**, so don't catch it expecting validation failures; a 422 surfaces as `APIError`. The JS SDK throws `UnprocessableEntityError` on 422. -- ASR segment `start` / `end` and `duration` are all in **seconds**. The Python SDK's `ASRResponse` docstring says milliseconds; that is wrong. See [speech-to-text](references/speech-to-text.md). +- ASR segment `start` / `end` and `duration` are all in **seconds**. In `fish-audio-sdk` 1.3.0 and earlier, the `ASRResponse` docstring says milliseconds; that is wrong. See [speech-to-text](references/speech-to-text.md). diff --git a/.mintlify/skills/fish-audio-sdk/references/speech-to-text.md b/.mintlify/skills/fish-audio-sdk/references/speech-to-text.md index 3fea2ed9..5c7eb35a 100644 --- a/.mintlify/skills/fish-audio-sdk/references/speech-to-text.md +++ b/.mintlify/skills/fish-audio-sdk/references/speech-to-text.md @@ -58,19 +58,19 @@ seg.start # float: seconds seg.end # float: seconds (can equal start) ``` -`duration`, `start`, and `end` are all in **seconds**. The SDK's `ASRResponse` docstring says milliseconds; that is wrong, so do not divide by 1000. +`duration`, `start`, and `end` are all in **seconds**. In `fish-audio-sdk` 1.3.0 and earlier, the `ASRResponse` docstring says milliseconds; that is wrong, so do not divide by 1000. Segment text has no punctuation, speaker markers, or cues, and can be normalized (for example `35` for `3.5`), so it does not always match `text` character for character. Segments are not speaker turns. -### Fields the Python SDK does not expose +### Fields the Python SDK exposes from 1.4.0 -In `fish-audio-sdk` 1.3.0, `ASRResponse` keeps only `text`, `duration`, and `segments`. It silently drops these response fields: +`fish-audio-sdk` 1.4.0 and later return these response fields on `ASRResponse`, each `None` when the API does not send it. In 1.3.0 and earlier, `ASRResponse` keeps only `text`, `duration`, and `segments` and silently drops them: - `speaker_turns` (`transcribe-1-pro`, when timestamps are requested); - `request_id` (`transcribe-1-pro`), also sent as the `x-request-id` header; - `language` (English name, such as `English`) and `language_code` (ISO 639-1, such as `en`), returned when the language is known. -`asr.transcribe()` also cannot send the `transcribe-1-pro` fields `tag_audio_events`, `diarize`, `num_speakers`, `min_speakers`, or `max_speakers`. For any of these, call the API directly. Field semantics are in the `fish-audio-api` skill (`POST /v1/asr`). +`asr.transcribe()` cannot send the `transcribe-1-pro` fields `tag_audio_events`, `diarize`, `num_speakers`, `min_speakers`, or `max_speakers`. For any of these, call the API directly. Field semantics are in the `fish-audio-api` skill (`POST /v1/asr`). ```python import os diff --git a/api-reference/endpoint/openapi-v1/speech-to-text.mdx b/api-reference/endpoint/openapi-v1/speech-to-text.mdx index b1fa93f8..1d687a25 100644 --- a/api-reference/endpoint/openapi-v1/speech-to-text.mdx +++ b/api-reference/endpoint/openapi-v1/speech-to-text.mdx @@ -101,10 +101,11 @@ A field that is not returned is absent from the JSON, never `null`. Do not depen `request_options=RequestOptions(additional_headers={"model": "transcribe-1-pro"})` to `asr.transcribe()`. In JavaScript, pass `{ headers: { model: "transcribe-1-pro" } }` as the second argument to - `speechToText.convert()`. The Python SDK currently returns only `text`, - `duration`, and `segments`, and neither SDK can send `tag_audio_events`, + `speechToText.convert()`. Neither SDK can send `tag_audio_events`, `diarize`, or the speaker-count hints. To use them, call the API directly, as - in the examples above. The JavaScript SDK returns the whole response body, + 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, but its `STTResponse` type declares only `text`, `duration`, and `segments`. diff --git a/developer-guide/sdk-guide/cookbook/batch-transcribe-with-language-hint.mdx b/developer-guide/sdk-guide/cookbook/batch-transcribe-with-language-hint.mdx index ee7567a2..d0e4734a 100644 --- a/developer-guide/sdk-guide/cookbook/batch-transcribe-with-language-hint.mdx +++ b/developer-guide/sdk-guide/cookbook/batch-transcribe-with-language-hint.mdx @@ -172,7 +172,7 @@ if (failed.length > 0) { -Each call returns an [`ASRResponse`](/api-reference/sdk/python/types#asrresponse-objects) with `.text` and `.duration` (seconds). With `transcribe-1-pro`, `text` can contain inline speaker markers such as `<|speaker:0|>` and cues such as `[laughter]`; see [Speaker markers](/features/speech-to-text#speaker-markers) to split it into turns. This recipe skips timestamps; pass `include_timestamps=True` (Python) or `ignore_timestamps: false` (JavaScript) for word-level `.segments`. The Python SDK currently returns only `text`, `duration`, and `segments`; to read `language_code`, call the API directly (see [Direct API](/features/speech-to-text#direct-api-messagepack)). +Each call returns an [`ASRResponse`](/api-reference/sdk/python/types#asrresponse-objects) with `.text` and `.duration` (seconds). With `transcribe-1-pro`, `text` can contain inline speaker markers such as `<|speaker:0|>` and cues such as `[laughter]`; see [Speaker markers](/features/speech-to-text#speaker-markers) to split it into turns. This recipe skips timestamps; pass `include_timestamps=True` (Python) or `ignore_timestamps: false` (JavaScript) for word-level `.segments`. In Python, `.language_code` holds the detected language, or your hint when the language cannot be determined (`fish-audio-sdk` 1.4.0 or later). A file that fails is recorded with its error, and the loop continues. After the summary, the script exits with a non-zero status if any file failed, so a scheduled job does not report success. A file that failed with 429, a 5xx status, or a network error such as a timeout is worth retrying later with backoff; for other 4xx errors, fix the file or the request first. diff --git a/developer-guide/sdk-guide/cookbook/realtime-transcription.mdx b/developer-guide/sdk-guide/cookbook/realtime-transcription.mdx index 01a3f63a..8fa2cf82 100644 --- a/developer-guide/sdk-guide/cookbook/realtime-transcription.mdx +++ b/developer-guide/sdk-guide/cookbook/realtime-transcription.mdx @@ -13,7 +13,7 @@ import Prerequisites from "/snippets/prerequisites.mdx"; -The SDKs do not wrap the realtime speech-to-text endpoint yet, so this recipe speaks the WebSocket protocol directly. Install a WebSocket client and a MessagePack library: +This recipe speaks the WebSocket protocol directly, so it needs no SDK. The Python SDK (`fish-audio-sdk` 1.5.0 or later) also wraps this endpoint as `client.asr.stream_websocket()`, and the JavaScript SDK (`fish-audio` 0.2.0 or later, Node.js only) as [`client.speechToText.convertRealtime()`](/api-reference/sdk/javascript/api-reference#speech-to-text). Install a WebSocket client and a MessagePack library: diff --git a/developer-guide/sdk-guide/cookbook/transcribe-to-captions.mdx b/developer-guide/sdk-guide/cookbook/transcribe-to-captions.mdx index df7d1c82..4a4d6aa0 100644 --- a/developer-guide/sdk-guide/cookbook/transcribe-to-captions.mdx +++ b/developer-guide/sdk-guide/cookbook/transcribe-to-captions.mdx @@ -226,8 +226,8 @@ Both tabs send the same request and write the same `captions.srt` and `captions. `speaker_turns`, with each turn's punctuated text and its start and end time. To keep speakers in separate cues, start a new cue at each turn boundary. In JavaScript, read `result.speaker_turns`; it is not in the SDK's TypeScript - type. The Python SDK does not return `speaker_turns`; to read it from the API, - see [Speaker turns](/features/speech-to-text#speaker-turns). + type. In Python, read `result.speaker_turns` (`fish-audio-sdk` 1.4.0 or + later). See [Speaker turns](/features/speech-to-text#speaker-turns). ## Related diff --git a/features/speech-to-text.mdx b/features/speech-to-text.mdx index 96dfd19f..79b91793 100644 --- a/features/speech-to-text.mdx +++ b/features/speech-to-text.mdx @@ -137,13 +137,15 @@ console.log(result.text); The response contains `text`, `duration` (seconds), `segments`, and `request_id`, plus [`speaker_turns`](#speaker-turns) when timestamps are requested, and `language_code` and `language` when the language is known. Do not depend on the order of keys in the JSON. If you use `transcribe-1`, rely on `text`, `duration`, `segments`, and the language fields. -The Python SDK currently returns only `text`, `duration`, and `segments`. To read the other fields, call the API directly (see [Direct API](#direct-api-messagepack)). +The Python SDK returns these fields on the result, for example `result.request_id` and `result.language_code` (`fish-audio-sdk` 1.4.0 or later; earlier versions keep only `text`, `duration`, and `segments`). - The Python SDK selects Pro through `RequestOptions.additional_headers`; - `asr.transcribe()` has no `model` argument, and it cannot send the - `transcribe-1-pro` fields such as `diarize`. The JavaScript example calls the - REST API directly so the header is explicit. For multipart uploads, let your + In the Python SDK, `model="transcribe-1-pro"` sends the `model` header. The + argument requires `fish-audio-sdk` 1.5.0 or later; on earlier versions, pass + `request_options=RequestOptions(additional_headers={"model": "transcribe-1-pro"})` + instead. `asr.transcribe()` cannot send the `transcribe-1-pro` fields such as + `diarize`. The JavaScript example calls the REST API directly so the header is + explicit. For multipart uploads, let your HTTP client set `Content-Type` and its boundary. @@ -366,7 +368,7 @@ The response reports the language in two fields, which are omitted when unknown - `language_code`: the two-letter ISO 639-1 code, such as `en`. Use it in application logic. - `language`: the language's English name, such as `English` or `Chinese`. Use it for display. -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. Responses report one language: for recordings that switch languages, `language` and `language_code` do not list every language spoken. The Python SDK does not return these fields; call the API directly to read them. +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. Responses report one language: for recordings that switch languages, `language` and `language_code` do not list every language spoken. The Python SDK returns them as `result.language` and `result.language_code` (`fish-audio-sdk` 1.4.0 or later). @@ -464,7 +466,7 @@ These values are examples, not a server guarantee. If a long request fails with ### Request IDs -`transcribe-1-pro` returns a unique `request_id` in the response body, both on success and on its own errors, and the same value in the `x-request-id` response header. Platform and network-edge errors do not carry it. Log it, and include it when you contact support. The Python SDK does not return it on success; read it with a [direct API call](#direct-api-messagepack), or from the error body as shown in [Errors](#errors). +`transcribe-1-pro` returns a unique `request_id` in the response body, both on success and on its own errors, and the same value in the `x-request-id` response header. Platform and network-edge errors do not carry it. Log it, and include it when you contact support. The Python SDK returns it as `result.request_id` (`fish-audio-sdk` 1.4.0 or later); on an error, read it from the error body as shown in [Errors](#errors). ### Errors @@ -558,7 +560,7 @@ for result in asyncio.run(transcribe_all(["speech.wav"])): ### Direct API (MessagePack) -`POST /v1/asr` also accepts a [MessagePack](https://msgpack.org) body instead of multipart form data, the same path the API reference links to for low-overhead, server-side calls. Calling the API directly also gives you the response fields the Python SDK does not return. Pack the audio bytes and options into one payload and set `Content-Type: application/msgpack`: +`POST /v1/asr` also accepts a [MessagePack](https://msgpack.org) body instead of multipart form data, the same path the API reference links to for low-overhead, server-side calls. Calling the API directly also lets you send the request fields the Python SDK cannot, such as `diarize`. Pack the audio bytes and options into one payload and set `Content-Type: application/msgpack`: ```python import os diff --git a/features/speech-to-text/realtime.mdx b/features/speech-to-text/realtime.mdx index 30ce5966..84796b52 100644 --- a/features/speech-to-text/realtime.mdx +++ b/features/speech-to-text/realtime.mdx @@ -76,7 +76,7 @@ The realtime endpoints of the [compatible APIs](/developer-guide/compat/capabili ## Quick start -The SDKs do not wrap this endpoint; you connect with any WebSocket client and exchange MessagePack messages. +The steps below use the protocol directly: you connect with any WebSocket client and exchange MessagePack messages. The Python SDK (`fish-audio-sdk` 1.5.0 or later) wraps this endpoint as `client.asr.stream_websocket()`, and the JavaScript SDK (`fish-audio` 0.2.0 or later, Node.js only) as [`client.speechToText.convertRealtime()`](/api-reference/sdk/javascript/api-reference#speech-to-text).