From e0f535f768675b51f6d98a7b0818747eb332c0bc Mon Sep 17 00:00:00 2001
From: fishaudio-bot <242899544+fishaudio-bot@users.noreply.github.com>
Date: Thu, 3 Dec 2026 05:01:59 +0000
Subject: [PATCH] chore: update Python SDK API reference
Auto-generated from fishaudio/fish-audio-python@55df9867805ce85eacfeb2dcdca18b9b69d86752
---
api-reference/sdk/python/client.mdx | 12 +--
api-reference/sdk/python/overview.mdx | 43 +++++++--
api-reference/sdk/python/resources.mdx | 116 +++++++++++++++++++++++--
api-reference/sdk/python/types.mdx | 24 +++++
api-reference/sdk/python/utils.mdx | 33 +++++--
5 files changed, 201 insertions(+), 27 deletions(-)
diff --git a/api-reference/sdk/python/client.mdx b/api-reference/sdk/python/client.mdx
index 1819c9c7..e86cac40 100644
--- a/api-reference/sdk/python/client.mdx
+++ b/api-reference/sdk/python/client.mdx
@@ -24,8 +24,7 @@ Synchronous Fish Audio API client.
# Generate speech
audio = client.tts.convert(text="Hello world")
with open("output.mp3", "wb") as f:
- for chunk in audio:
- f.write(chunk)
+ f.write(audio)
# List voices
voices = client.voices.list(page_size=20)
@@ -120,16 +119,17 @@ Asynchronous Fish Audio API client.
**Example**:
```python
+ import asyncio
+
from fishaudio import AsyncFishAudio
async def main():
client = AsyncFishAudio(api_key="your_api_key")
# Generate speech
- audio = client.tts.convert(text="Hello world")
- async with aiofiles.open("output.mp3", "wb") as f:
- async for chunk in audio:
- await f.write(chunk)
+ audio = await client.tts.convert(text="Hello world")
+ with open("output.mp3", "wb") as f:
+ f.write(audio)
# List voices
voices = await client.voices.list(page_size=20)
diff --git a/api-reference/sdk/python/overview.mdx b/api-reference/sdk/python/overview.mdx
index 3aa5a432..a9c05739 100644
--- a/api-reference/sdk/python/overview.mdx
+++ b/api-reference/sdk/python/overview.mdx
@@ -150,6 +150,21 @@ audio = client.tts.convert(
)
```
+**Language of the text:**
+
+```python
+# On s2.1-pro, "$300" is read as pesos with es-MX and as dólares with es.
+# s3-pro, the default, normalizes a regional tag with its base language and
+# reads this "$300" as pesos with es and es-MX alike.
+audio = client.tts.convert(
+ text="La entrada cuesta $300.",
+ model="s2.1-pro",
+ language="es-MX",
+)
+```
+
+`language` is a BCP-47 tag such as `en`, `es-MX` or `zh-CN`. Regional conventions (`es-MX` against `es`) apply on `s2.1-pro`, `s2-pro` and `s1`; `s3-pro` reads a regional tag as its base language. It only changes how numbers, dates, units and symbols are spelled out before synthesis (and word-timestamp alignment); it does not change the voice or accent. Without it, the API detects the language of each chunk, which is also the right choice for text that mixes languages. It is accepted by every text-to-speech method and by `TTSConfig`; on `stream_websocket` it applies to the whole session. See [supported normalization languages](https://docs.fish.audio/features/text-to-speech#supported-normalization-languages).
+
**Reusable configuration:**
```python
@@ -197,7 +212,7 @@ with client.tts.stream_with_timestamps(text="Long content...", format="opus") as
Text without words (only punctuation, or a sound tag such as `[sigh]`) still produces audio, but the API has no timings for it: `segments` is then empty and `result.duration` is `None`.
-`s1` and `transcribe-1` are deprecated and will be retired on December 31, 2026. After that date, requests that specify them are served by `s3-pro` and `transcribe-2-pro`. Using a deprecated model emits a `FutureWarning`; with Python's default warning filters it is shown once per calling line. A coroutine scheduled with `asyncio.create_task` or `gather` runs from asyncio's code, so its warning points there and is shown once in all. See [Model Deprecations](https://docs.fish.audio/developer-guide/models-pricing/deprecations).
+`s1` and `transcribe-1` are deprecated and will be retired on December 31, 2026. After that date, requests that specify them are served by `s3-pro` and `transcribe-2-pro`. Using a deprecated model emits a `FutureWarning`; with Python's default warning filters it is shown once per calling line. A coroutine scheduled with `asyncio.create_task` or `gather` runs from asyncio's code, so its warning points there and is shown once in all. A transcription that names no model runs on the API's default model (`transcribe-1` until it is retired, `transcribe-2-pro` after) and emits a `FutureWarning`, shown as the deprecation warnings above are; pass a model (the `model` argument or a `model` header) to silence it. Write the model ID exactly, for example `transcribe-2-pro`: the API runs a name it does not know on its default model, and the SDK does not check names. A model that only an httpx request hook or auth flow adds is not seen, so such a request still gets the warning; if you also turn warnings into errors, pass `model` in the call. See [Model Deprecations](https://docs.fish.audio/developer-guide/models-pricing/deprecations).
[Learn more](https://docs.fish.audio/developer-guide/sdk-guide/python/text-to-speech)
@@ -205,7 +220,8 @@ Text without words (only punctuation, or a sound tag such as `[sigh]`) still pro
```python
# transcribe-2-pro is the recommended model; without model, the request runs on transcribe-1,
-# which is deprecated and will be retired on December 31, 2026 (then served by transcribe-2-pro).
+# which is deprecated and will be retired on December 31, 2026 (then served by transcribe-2-pro),
+# and emits a FutureWarning.
with open("meeting.wav", "rb") as f:
result = client.asr.transcribe(audio=f.read(), model="transcribe-2-pro")
@@ -222,8 +238,20 @@ for turn in result.speaker_turns or []:
# Language of the transcript, when the API returns it
print(result.language_code) # e.g. "en"
+
+# Plain transcript on transcribe-2-pro: no speaker markers, no cues such as [laughter]
+with open("meeting.wav", "rb") as f:
+ plain = client.asr.transcribe(
+ audio=f.read(),
+ model="transcribe-2-pro",
+ diarize=False,
+ tag_audio_events=False,
+ )
+print(plain.text)
```
+The Pro models also take `num_speakers`, `min_speakers` and `max_speakers` (speaker-count hints), and `transcribe-2-pro` takes `text_format="spoken"` (numbers in words), `verbatim=False` (asks the model to leave out fillers and false starts) and `keyterms=["Fish Audio", ...]` (terms to spell as listed). Options left as `None` are not sent; the API ignores those a model does not use.
+
[Learn more](https://docs.fish.audio/developer-guide/sdk-guide/python/speech-to-text)
**Realtime (Preview):** stream live audio to `transcribe-stream-1` and get the transcript turn by turn. Send 16-bit mono PCM in 20–40 ms chunks as you capture it:
@@ -383,9 +411,9 @@ client = FishAudio(httpx_client=http_client)
```python
from fishaudio.exceptions import (
+ APIError,
AuthenticationError,
RateLimitError,
- ValidationError,
FishAudioError,
)
@@ -395,12 +423,15 @@ except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Rate limit exceeded")
-except ValidationError as e:
- print(f"Invalid request: {e}")
+except APIError as e:
+ # Any other error response, such as 400 for a request the API rejects
+ print(f"API error {e.status}: {e.message}")
except FishAudioError as e:
- print(f"API error: {e}")
+ print(f"Error: {e}")
```
+A value the SDK can check before sending, such as a `speed` outside 0.5 to 2.0, raises pydantic's `ValidationError` instead, and no request is sent. `fishaudio.exceptions.ValidationError` is not raised by the SDK.
+
Every `APIError` carries the headers of the error response. When you contact support, include the trace id and the error code. Either can be absent.
```python
diff --git a/api-reference/sdk/python/resources.mdx b/api-reference/sdk/python/resources.mdx
index c6a57b77..b70f20e0 100644
--- a/api-reference/sdk/python/resources.mdx
+++ b/api-reference/sdk/python/resources.mdx
@@ -340,6 +340,7 @@ def stream(*,
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None) -> AudioStream
@@ -355,6 +356,7 @@ Stream text-to-speech audio chunks.
- `format` - Audio format - "mp3", "wav", "pcm", or "opus" (overrides config.format if provided)
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -394,6 +396,7 @@ def convert(*,
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None) -> bytes
@@ -412,6 +415,7 @@ For chunk-by-chunk processing, use stream() instead.
- `format` - Audio format - "mp3", "wav", "pcm", or "opus" (overrides config.format if provided)
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -455,6 +459,7 @@ def stream_with_timestamps(
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None
@@ -476,6 +481,7 @@ The returned stream keeps the timings up to date in `stream.segments`.
are uncompressed, which keeps sample positions exact.
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -517,6 +523,7 @@ def convert_with_timestamps(
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None
@@ -538,6 +545,7 @@ and timings while they arrive, use stream_with_timestamps() instead.
are uncompressed, which keeps sample positions exact.
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -582,6 +590,7 @@ def stream_websocket(
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
max_workers: int = 10,
@@ -600,6 +609,7 @@ Perfect for conversational AI, live captioning, and streaming applications.
- `format` - Audio format - "mp3", "wav", "pcm", or "opus" (overrides config.format if provided)
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -698,6 +708,7 @@ async def stream(
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None) -> AsyncAudioStream
@@ -713,6 +724,7 @@ Stream text-to-speech audio chunks (async).
- `format` - Audio format - "mp3", "wav", "pcm", or "opus" (overrides config.format if provided)
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -753,6 +765,7 @@ async def convert(*,
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None) -> bytes
@@ -771,6 +784,7 @@ For chunk-by-chunk processing, use stream() instead.
- `format` - Audio format - "mp3", "wav", "pcm", or "opus" (overrides config.format if provided)
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -814,6 +828,7 @@ async def stream_with_timestamps(
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None
@@ -835,6 +850,7 @@ The returned stream keeps the timings up to date in `stream.segments`.
are uncompressed, which keeps sample positions exact.
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -877,6 +893,7 @@ async def convert_with_timestamps(
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
request_options: Optional[RequestOptions] = None
@@ -898,6 +915,7 @@ and timings while they arrive, use stream_with_timestamps() instead.
are uncompressed, which keeps sample positions exact.
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -942,6 +960,7 @@ async def stream_websocket(text_stream: AsyncIterable[Union[str, TextEvent,
format: Optional[AudioFormat] = None,
latency: Optional[LatencyMode] = None,
speed: Optional[float] = None,
+ language: Optional[str] = None,
config: TTSConfig = TTSConfig(),
model: Union[Model, str] = "s3-pro",
ws_options: Optional[WebSocketOptions] = None)
@@ -959,6 +978,7 @@ Perfect for conversational AI, live captioning, and streaming applications.
- `format` - Audio format - "mp3", "wav", "pcm", or "opus" (overrides config.format if provided)
- `latency` - Latency mode - "normal", "balanced" or "low" (overrides config.latency if provided)
- `speed` - Speech speed multiplier, e.g. 1.5 for 1.5x speed (overrides config.prosody.speed if provided)
+- `language` - BCP-47 tag of the text, e.g. "es-MX", for text normalization (overrides config.language if provided)
- `config` - TTS configuration (audio settings, voice, model parameters)
- `model` - TTS model to use. Deprecated models ("s1", which will be
retired on December 31, 2026, and "speech-1.5"/"speech-1.6")
@@ -1277,6 +1297,14 @@ def transcribe(
audio: bytes,
language: Optional[str] = OMIT,
include_timestamps: bool = True,
+ tag_audio_events: Optional[bool] = None,
+ diarize: Optional[ASRDiarize] = None,
+ num_speakers: Optional[int] = None,
+ min_speakers: Optional[int] = None,
+ max_speakers: Optional[int] = None,
+ text_format: Optional[ASRTextFormat] = None,
+ verbatim: Optional[bool] = None,
+ keyterms: Optional[Sequence[str]] = None,
model: Optional[str] = None,
request_options: Optional[RequestOptions] = None) -> ASRResponse
```
@@ -1289,14 +1317,39 @@ Transcribe audio to text.
- `language` - 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)
+- `tag_audio_events` - Pro models. False removes emotion and vocal-event
+ cues such as ``[laughter]`` from the text and speaker turns.
+ Server default: True
+- `diarize` - Pro models. False removes the ``<|speaker:N|>`` markers
+ from the text and omits speaker turns. Server default: "auto"
+- `num_speakers` - Pro models. Expected number of speakers, a
+ best-effort hint. Not with min_speakers, max_speakers or
+ diarize=False
+- `min_speakers` - Pro models. Lower bound on the number of speakers
+- `max_speakers` - Pro models. Upper bound on the number of speakers
+- `text_format` - transcribe-2-pro. "written" (default) or "spoken"
+ numbers, dates, times and amounts
+- `verbatim` - transcribe-2-pro. False asks the model to leave out
+ filler sounds, stutters and false starts. Server default: True
+- `keyterms` - transcribe-2-pro. Up to 128 words or short phrases, such
+ as names and products, to spell as listed. With keyterms, the
+ API may not follow text_format="spoken" or verbatim=False
- `model` - ASR model, e.g. "transcribe-2-pro" (recommended). Sent as the
``model`` header and takes precedence over one in request_options.
- If not provided and request_options sets no ``model`` header, the
- request runs on the API's default model, transcribe-1.
+ When the outgoing request carries no ``model`` header (from
+ this argument, request_options, or headers set on a custom
+ httpx client), it runs on the API's default model, transcribe-1.
transcribe-1 is deprecated and will be retired on December 31,
2026; after that date, the requests it serves, including those
with no ``model`` header, are served by transcribe-2-pro.
- Passing "transcribe-1" emits a FutureWarning.
+ A request that carries no model, or an empty one, emits a
+ FutureWarning; pass a model (this argument or a ``model``
+ header) to silence it. A model that only an httpx request
+ hook adds is not seen, so such a request still gets it.
+ "transcribe-1" given as
+ ``model``, or as a ``model`` header in request_options when
+ ``model`` is not given, emits a FutureWarning; one set only
+ in a custom httpx client's headers is not seen.
- `request_options` - Request-level overrides
@@ -1320,6 +1373,15 @@ Transcribe audio to text.
print(result.text)
for segment in result.segments:
print(f"{segment.start}-{segment.end}: {segment.text}")
+
+ # Plain transcript on transcribe-2-pro: no speaker markers, no cues
+ plain = client.asr.transcribe(
+ audio=audio_bytes,
+ model="transcribe-2-pro",
+ diarize=False,
+ tag_audio_events=False,
+ )
+ print(plain.text)
```
@@ -1449,6 +1511,14 @@ async def transcribe(
audio: bytes,
language: Optional[str] = OMIT,
include_timestamps: bool = True,
+ tag_audio_events: Optional[bool] = None,
+ diarize: Optional[ASRDiarize] = None,
+ num_speakers: Optional[int] = None,
+ min_speakers: Optional[int] = None,
+ max_speakers: Optional[int] = None,
+ text_format: Optional[ASRTextFormat] = None,
+ verbatim: Optional[bool] = None,
+ keyterms: Optional[Sequence[str]] = None,
model: Optional[str] = None,
request_options: Optional[RequestOptions] = None) -> ASRResponse
```
@@ -1461,14 +1531,39 @@ Transcribe audio to text (async).
- `language` - 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)
+- `tag_audio_events` - Pro models. False removes emotion and vocal-event
+ cues such as ``[laughter]`` from the text and speaker turns.
+ Server default: True
+- `diarize` - Pro models. False removes the ``<|speaker:N|>`` markers
+ from the text and omits speaker turns. Server default: "auto"
+- `num_speakers` - Pro models. Expected number of speakers, a
+ best-effort hint. Not with min_speakers, max_speakers or
+ diarize=False
+- `min_speakers` - Pro models. Lower bound on the number of speakers
+- `max_speakers` - Pro models. Upper bound on the number of speakers
+- `text_format` - transcribe-2-pro. "written" (default) or "spoken"
+ numbers, dates, times and amounts
+- `verbatim` - transcribe-2-pro. False asks the model to leave out
+ filler sounds, stutters and false starts. Server default: True
+- `keyterms` - transcribe-2-pro. Up to 128 words or short phrases, such
+ as names and products, to spell as listed. With keyterms, the
+ API may not follow text_format="spoken" or verbatim=False
- `model` - ASR model, e.g. "transcribe-2-pro" (recommended). Sent as the
``model`` header and takes precedence over one in request_options.
- If not provided and request_options sets no ``model`` header, the
- request runs on the API's default model, transcribe-1.
+ When the outgoing request carries no ``model`` header (from
+ this argument, request_options, or headers set on a custom
+ httpx client), it runs on the API's default model, transcribe-1.
transcribe-1 is deprecated and will be retired on December 31,
2026; after that date, the requests it serves, including those
with no ``model`` header, are served by transcribe-2-pro.
- Passing "transcribe-1" emits a FutureWarning.
+ A request that carries no model, or an empty one, emits a
+ FutureWarning; pass a model (this argument or a ``model``
+ header) to silence it. A model that only an httpx request
+ hook adds is not seen, so such a request still gets it.
+ "transcribe-1" given as
+ ``model``, or as a ``model`` header in request_options when
+ ``model`` is not given, emits a FutureWarning; one set only
+ in a custom httpx client's headers is not seen.
- `request_options` - Request-level overrides
@@ -1492,6 +1587,15 @@ Transcribe audio to text (async).
print(result.text)
for segment in result.segments:
print(f"{segment.start}-{segment.end}: {segment.text}")
+
+ # Plain transcript on transcribe-2-pro: no speaker markers, no cues
+ plain = await client.asr.transcribe(
+ audio=audio_bytes,
+ model="transcribe-2-pro",
+ diarize=False,
+ tag_audio_events=False,
+ )
+ print(plain.text)
```
diff --git a/api-reference/sdk/python/types.mdx b/api-reference/sdk/python/types.mdx
index f0af88be..f36c8bdd 100644
--- a/api-reference/sdk/python/types.mdx
+++ b/api-reference/sdk/python/types.mdx
@@ -117,6 +117,23 @@ is shown: by default once per such line, so a loop does not repeat it. A
coroutine scheduled with asyncio.create_task or gather runs from asyncio's
own code, so its warning is attributed there and shown once in all.
+
+
+#### warn\_if\_no\_asr\_model
+
+```python
+def warn_if_no_asr_model(model: Optional[str]) -> None
+```
+
+Emit a FutureWarning when a transcription is sent without a model.
+
+``model`` is the value the request sends; None or an empty string means
+none, and the API then runs the request on its default model. Attributed to
+the line that called the SDK method, as warn_if_deprecated_model is, so
+Python's warning filters decide how often it is shown: by default once
+per such line; under an "error" filter it raises on every call, before
+the request is sent.
+
# fishaudio.types.tts
@@ -199,6 +216,11 @@ All parameters have sensible defaults.
- `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
+- `language` - BCP-47 tag of the text's language, such as "en", "es-MX" or "zh-CN".
+ Only changes how text normalization spells out numbers, dates, units
+ and symbols (and word-timestamp alignment); it does not change the
+ voice or accent. Sent as given; the API checks it. Default: None
+ (not sent, the API detects the language of each chunk)
- `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),
@@ -240,6 +262,8 @@ For the HTTP API, parameters are passed directly to methods.
- `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
+- `language` - BCP-47 tag of the text's language for text normalization.
+- `Default` - None, which leaves the field out of the request
- `latency` - Generation mode. Options: "normal", "balanced". Default: "balanced"
"low" is also accepted; it gives earlier first audio on s3-pro.
- `prosody` - Speech speed and volume settings. Default: None
diff --git a/api-reference/sdk/python/utils.mdx b/api-reference/sdk/python/utils.mdx
index 30f93ea2..6233b09c 100644
--- a/api-reference/sdk/python/utils.mdx
+++ b/api-reference/sdk/python/utils.mdx
@@ -20,13 +20,27 @@ Play audio using various playback methods.
**Arguments**:
- `audio` - Audio bytes or iterable of bytes
-- `notebook` - Use Jupyter notebook playback (IPython.display.Audio)
-- `use_ffmpeg` - Use ffplay for playback (default, falls back to sounddevice)
+- `notebook` - Use Jupyter notebook playback (IPython.display.Audio).
+ ``use_ffmpeg`` is then ignored: neither ffplay nor sounddevice
+ is used.
+- `use_ffmpeg` - Outside notebook mode, play with ffplay (the default). If ffplay is not
+ installed, DependencyError is raised; there is no fallback.
+ Playback falls back to sounddevice only when ffplay exits with a
+ non-zero status (an ffplay that reports a problem but exits with
+ 0 counts as played). False plays with sounddevice (the
+ ``[utils]`` extra).
**Raises**:
-- `DependencyError` - If required playback tool is not installed
+- `DependencyError` - If IPython is not installed (``notebook=True``, which
+ is checked first), if ffplay is not installed (``use_ffmpeg=True``), or
+ sounddevice or soundfile cannot be imported when sounddevice is
+- `used` - any ImportError from importing them (a missing package, or
+ a missing native binding) is raised as DependencyError, with the
+ original error chained to it. Other errors from importing them
+ (an OSError for a missing PortAudio library, say) are raised as
+ they are.
**Examples**:
@@ -43,7 +57,7 @@ Play audio using various playback methods.
# In Jupyter notebook
play(audio, notebook=True)
- # Force sounddevice fallback
+ # Play with sounddevice instead of ffplay
play(audio, use_ffmpeg=False)
```
@@ -96,7 +110,7 @@ Audio streaming utility.
#### stream
```python
-def stream(audio_stream: Iterator[bytes]) -> bytes
+def stream(audio_stream: Iterable[bytes]) -> bytes
```
Stream audio in real-time while playing it with mpv.
@@ -106,7 +120,7 @@ simultaneously captures it to return the complete audio buffer.
**Arguments**:
-- `audio_stream` - Iterator of audio byte chunks
+- `audio_stream` - Audio byte chunks, such as ``client.tts.stream(...)``
**Returns**:
@@ -125,10 +139,11 @@ simultaneously captures it to return the complete audio buffer.
from fishaudio import FishAudio, stream
client = FishAudio(api_key="...")
- audio_stream = client.tts.convert(text="Hello world")
- # Stream and play in real-time, get complete audio
- complete_audio = stream(audio_stream)
+ # Stream and play in real-time, get complete audio. The with block
+ # closes the response even if playback fails (mpv missing, say).
+ with client.tts.stream(text="Hello world") as audio_stream:
+ complete_audio = stream(audio_stream)
# Save the captured audio
with open("output.mp3", "wb") as f: