Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions api-reference/endpoint/openapi-v1/speech-to-text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ A field that is not returned is absent from the JSON, never `null`. Do not depen

<Note>
Both SDKs select `transcribe-1-pro` through the `model` header. In Python,
pass
`request_options=RequestOptions(additional_headers={"model": "transcribe-1-pro"})`
to `asr.transcribe()`. In JavaScript, pass
pass `model="transcribe-1-pro"` to `asr.transcribe()` (`fish-audio-sdk` 1.5.0
or later; on earlier versions, pass
`request_options=RequestOptions(additional_headers={"model": "transcribe-1-pro"})`).
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`,
Expand Down
9 changes: 2 additions & 7 deletions developer-guide/models-pricing/migrate-from-transcribe-1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,12 @@ curl --request POST https://api.fish.audio/v1/asr \

```python Python
from fishaudio import FishAudio
from fishaudio.core import RequestOptions

client = FishAudio() # reads FISH_API_KEY

with open("speech.wav", "rb") as f:
result = client.asr.transcribe(
audio=f.read(),
request_options=RequestOptions(
additional_headers={"model": "transcribe-1-pro"}
),
)
# model sends the header; it requires fish-audio-sdk 1.5.0 or later
result = client.asr.transcribe(audio=f.read(), model="transcribe-1-pro")

print(result.text)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ import Prerequisites from "/snippets/prerequisites.mdx";

## Recipe

This recipe uses `transcribe-1-pro`, which handles recordings up to 60 minutes long. Every tab selects it with the `model` request header; without that header, the request is served and billed as `transcribe-1`.
This recipe uses `transcribe-1-pro`, which handles recordings up to 60 minutes long. Every tab selects it with the `model` request header, which the Python SDK sends for its `model` argument; without that header, the request is served and billed as `transcribe-1`.

Read each file's bytes from disk and pass them to [`asr.transcribe()`](/api-reference/sdk/python/resources#transcribe) with `language` set to a lowercase ISO 639-1 code such as `en`, `zh`, or `ja`. Other forms, such as `en-US` or `English`, may be rejected with 400. Pass `language` when you know the source language. Detection still runs, and the hint does not force the transcript into that language; the hint is reported as `language_code` when the language cannot be determined. See [Language](/features/speech-to-text#language) for details.

Collect one result row per file as you go. If a file cannot be read, its request fails with a network error such as a timeout, or the API returns an error for it, record the error in that file's row and move on to the next file.

Install the Python SDK first: `pip install fish-audio-sdk`.
Install the Python SDK first: `pip install --upgrade fish-audio-sdk`.

<Note>
The `model` argument of `asr.transcribe()` requires `fish-audio-sdk` 1.5.0 or
later.
</Note>

<CodeGroup>

Expand All @@ -32,10 +37,7 @@ client = FishAudio()

paths = ["speech.wav"] # add more file paths here
language = "en"
options = RequestOptions(
timeout=900, # long recordings can take several minutes
additional_headers={"model": "transcribe-1-pro"},
)
options = RequestOptions(timeout=900) # long recordings can take several minutes

results = []
for path in paths:
Expand All @@ -44,6 +46,7 @@ for path in paths:
audio = f.read()
transcript = client.asr.transcribe(
audio=audio,
model="transcribe-1-pro",
language=language,
include_timestamps=False,
request_options=options,
Expand Down Expand Up @@ -81,10 +84,8 @@ async def main():
async with AsyncFishAudio() as client:
paths = ["speech.wav"] # add more file paths here
language = "en"
options = RequestOptions(
timeout=900, # long recordings can take several minutes
additional_headers={"model": "transcribe-1-pro"},
)
# long recordings can take several minutes
options = RequestOptions(timeout=900)

results = []
for path in paths:
Expand All @@ -93,6 +94,7 @@ async def main():
audio = f.read()
transcript = await client.asr.transcribe(
audio=audio,
model="transcribe-1-pro",
language=language,
include_timestamps=False,
request_options=options,
Expand Down
Loading
Loading