diff --git a/README.md b/README.md index 5c5174d..4569f8a 100644 --- a/README.md +++ b/README.md @@ -102,10 +102,12 @@ s21_audio = client.tts.convert( model="s2.1-pro", ) -# Free to use, including on a new account with no API credit +# S3 Pro Free: the same model at $0 under fair-use limits, for testing and +# prototyping, including on a $0 API balance. The earlier name "s2.1-pro-free" +# is still accepted and is served by s3-pro-free. free_audio = client.tts.convert( text="Free speech", - model="s2.1-pro-free", + model="s3-pro-free", ) # Drama 3: our most expressive model (uses API credit) @@ -180,26 +182,26 @@ 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 `s2.1-pro` and `transcribe-1-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. 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) ### Speech-to-Text ```python -# transcribe-1-pro is the recommended model; without model, the request runs on transcribe-1, -# which is deprecated and will be retired on December 31, 2026. +# 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). with open("meeting.wav", "rb") as f: - result = client.asr.transcribe(audio=f.read(), model="transcribe-1-pro") + result = client.asr.transcribe(audio=f.read(), model="transcribe-2-pro") -# On transcribe-1-pro, text keeps <|speaker:N|> markers; speaker_turns has clean text per speaker. +# On transcribe-2-pro, text keeps <|speaker:N|> markers; speaker_turns has clean text per speaker. print(result.text) # Word-level timestamps for segment in result.segments: print(f"[{segment.start:.2f}s - {segment.end:.2f}s] {segment.text}") -# Speaker turns (transcribe-1-pro, returned with timestamps) +# Speaker turns (transcribe-2-pro, returned with timestamps) for turn in result.speaker_turns or []: print(f"[{turn.start:.2f}s - {turn.end:.2f}s] {turn.speaker}: {turn.text}") diff --git a/src/fishaudio/resources/asr.py b/src/fishaudio/resources/asr.py index a6b4b01..0c6a86a 100644 --- a/src/fishaudio/resources/asr.py +++ b/src/fishaudio/resources/asr.py @@ -102,13 +102,13 @@ def transcribe( 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) - model: ASR model, e.g. "transcribe-1-pro" (recommended). Sent as the + 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. 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-1-pro. + with no ``model`` header, are served by transcribe-2-pro. Passing "transcribe-1" emits a FutureWarning. request_options: Request-level overrides @@ -124,7 +124,7 @@ def transcribe( audio_bytes = f.read() result = client.asr.transcribe( - audio=audio_bytes, model="transcribe-1-pro" + audio=audio_bytes, model="transcribe-2-pro" ) print(result.text) for segment in result.segments: @@ -299,13 +299,13 @@ async def transcribe( 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) - model: ASR model, e.g. "transcribe-1-pro" (recommended). Sent as the + 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. 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-1-pro. + with no ``model`` header, are served by transcribe-2-pro. Passing "transcribe-1" emits a FutureWarning. request_options: Request-level overrides @@ -321,7 +321,7 @@ async def transcribe( audio_bytes = await f.read() result = await client.asr.transcribe( - audio=audio_bytes, model="transcribe-1-pro" + audio=audio_bytes, model="transcribe-2-pro" ) print(result.text) for segment in result.segments: diff --git a/src/fishaudio/types/shared.py b/src/fishaudio/types/shared.py index 878cf9a..90de043 100644 --- a/src/fishaudio/types/shared.py +++ b/src/fishaudio/types/shared.py @@ -36,21 +36,25 @@ def _get_response_headers(model: BaseModel) -> httpx.Headers: return model.__dict__.get("_response_headers", httpx.Headers()) -# Model types -Model = Literal["s1", "s2-pro", "s2.1-pro", "s2.1-pro-free", "drama-3", "s3-pro"] +# Model types. "s3-pro-free" is the free tier of S3 Pro (fair-use limits). +# "s2.1-pro-free" is its earlier name: the API still accepts it and serves it +# with s3-pro-free. +Model = Literal[ + "s1", "s2-pro", "s2.1-pro", "s2.1-pro-free", "drama-3", "s3-pro", "s3-pro-free" +] # Deprecated models, mapped to the warning shown when one is used. _SPEECH_1_MESSAGE = "Model '{model}' is deprecated. Use 's3-pro' instead." _S1_MESSAGE = ( "Model 's1' is deprecated and will be retired on December 31, 2026. " - "After that date, requests that specify 's1' are served by 's2.1-pro' " - "and billed as 's2.1-pro'. Use 's2.1-pro' instead." + "After that date, requests that specify 's1' are served by 's3-pro' " + "and billed as 's3-pro'. Use 's3-pro' instead." ) _TRANSCRIBE_1_MESSAGE = ( "Model 'transcribe-1' is deprecated and will be retired on December 31, " "2026. After that date, requests that specify 'transcribe-1' are served " - "by 'transcribe-1-pro' and billed as 'transcribe-1-pro'. " - "Use 'transcribe-1-pro' instead." + "by 'transcribe-2-pro' and billed as 'transcribe-2-pro'. " + "Use 'transcribe-2-pro' instead." ) DEPRECATED_TTS_MODELS: dict[str, str] = { diff --git a/tests/unit/test_deprecated_models.py b/tests/unit/test_deprecated_models.py index 1bafe94..2c27278 100644 --- a/tests/unit/test_deprecated_models.py +++ b/tests/unit/test_deprecated_models.py @@ -21,14 +21,14 @@ S1_MESSAGE = ( "Model 's1' is deprecated and will be retired on December 31, 2026. " - "After that date, requests that specify 's1' are served by 's2.1-pro' " - "and billed as 's2.1-pro'. Use 's2.1-pro' instead." + "After that date, requests that specify 's1' are served by 's3-pro' " + "and billed as 's3-pro'. Use 's3-pro' instead." ) TRANSCRIBE_1_MESSAGE = ( "Model 'transcribe-1' is deprecated and will be retired on December 31, " "2026. After that date, requests that specify 'transcribe-1' are served " - "by 'transcribe-1-pro' and billed as 'transcribe-1-pro'. " - "Use 'transcribe-1-pro' instead." + "by 'transcribe-2-pro' and billed as 'transcribe-2-pro'. " + "Use 'transcribe-2-pro' instead." ) @@ -327,7 +327,8 @@ def work() -> None: class TestCurrentModelsDoNotWarn: @pytest.mark.parametrize("call", SYNC_TTS, ids=_ids) @pytest.mark.parametrize( - "model", ["s2.1-pro", "s2.1-pro-free", "s2-pro", "drama-3"] + "model", + ["s3-pro", "s3-pro-free", "s2.1-pro", "s2.1-pro-free", "s2-pro", "drama-3"], ) def test_sync_tts(self, call, model): with warnings.catch_warnings(): @@ -337,7 +338,8 @@ def test_sync_tts(self, call, model): @pytest.mark.asyncio @pytest.mark.parametrize("call", ASYNC_TTS, ids=_ids) @pytest.mark.parametrize( - "model", ["s2.1-pro", "s2.1-pro-free", "s2-pro", "drama-3"] + "model", + ["s3-pro", "s3-pro-free", "s2.1-pro", "s2.1-pro-free", "s2-pro", "drama-3"], ) async def test_async_tts(self, call, model): with warnings.catch_warnings(): diff --git a/tests/unit/test_tts.py b/tests/unit/test_tts.py index dae917f..882d382 100644 --- a/tests/unit/test_tts.py +++ b/tests/unit/test_tts.py @@ -1,5 +1,6 @@ """Tests for TTS namespace client.""" +import typing from unittest.mock import AsyncMock, Mock import ormsgpack @@ -8,6 +9,7 @@ from fishaudio.core import AsyncClientWrapper, ClientWrapper, RequestOptions from fishaudio.resources.tts import AsyncTTSClient, TTSClient from fishaudio.types import Prosody, ReferenceAudio, TTSConfig +from fishaudio.types.shared import Model @pytest.fixture @@ -87,17 +89,24 @@ def test_convert_basic(self, tts_client, mock_client_wrapper): call_args = mock_client_wrapper.request.call_args assert call_args[1]["headers"]["model"] == "s3-pro" - def test_convert_with_free_model(self, tts_client, mock_client_wrapper): - """Test the free s2.1-pro-free model is sent as the model header.""" + def test_model_type_names_the_free_tier(self): + """The Model type names s3-pro-free and keeps its earlier name.""" + names = typing.get_args(Model) + assert "s3-pro-free" in names + assert "s2.1-pro-free" in names + + @pytest.mark.parametrize("model", ["s3-pro-free", "s2.1-pro-free"]) + def test_convert_with_free_model(self, tts_client, mock_client_wrapper, model): + """Test the free model (and its earlier name) is sent unchanged.""" mock_response = Mock() mock_response.iter_bytes.return_value = iter([b"audio"]) mock_client_wrapper.request.return_value = mock_response - audio = tts_client.convert(text="Hello world", model="s2.1-pro-free") + audio = tts_client.convert(text="Hello world", model=model) assert audio == b"audio" call_args = mock_client_wrapper.request.call_args - assert call_args[1]["headers"]["model"] == "s2.1-pro-free" + assert call_args[1]["headers"]["model"] == model def test_convert_with_drama_3(self, tts_client, mock_client_wrapper): """Test the drama-3 model is sent as the model header."""