Skip to content

feat(asr): support transcribe-stream-2 and its text_format option - #201

Draft
lumpinif wants to merge 2 commits into
mainfrom
feat/transcribe-stream-2
Draft

lumpinif wants to merge 2 commits into
mainfrom
feat/transcribe-stream-2

Conversation

@lumpinif

@lumpinif lumpinif commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Adds transcribe-stream-2 support to realtime speech to text, for the launch on 2026-12-02. Protocol per fishaudio/docs#403.

Before / after

  • Before: stream_websocket could connect with model="transcribe-stream-2" (any string was passed through), but there was no way to send results.text_format, the one field only transcribe-stream-2 takes. The docstring and README named transcribe-stream-1 only.
  • After:
    • stream_websocket (sync and async) takes text_format: "spoken" | "written", and ASRResults has the same field (new type alias ASRTextFormat, exported from fishaudio.types). The direct parameter wins over config.results.text_format, like drafts and diarize.
    • The field is sent only when set. None leaves it out, because transcribe-stream-1 refuses it whatever its value, null included.
    • The model docstring and the README name both models. transcribe-stream-1 stays the default.

Verified against the live API (public endpoint, test key)

The clip was TTS audio of "I paid $25 at 3:30 pm on March 4th, and it cost 12 percent more.", sent as 16 kHz PCM with manual turn detection.

Session session_started.config committed text
transcribe-stream-2, no text_format model transcribe-stream-2, text_format: written I paid 25 dollars at 3:30 PM on March 4th, and it cost 12% more.
transcribe-stream-2, text_format="spoken" (async client, direct parameter) text_format: spoken I paid twenty-five dollars at three thirty PM on March fourth, and it cost twelve percent more.
transcribe-stream-2, config.results.text_format="written" text_format: written I paid 25 dollars at 3:30 PM … 12% more.
transcribe-stream-1, text_format="spoken" — ASRRealtimeError invalid_config: "results.text_format is not supported by this model"
transcribe-stream-1, default model transcribe-stream-1, no text_format key spoken-style text, as before

Tests

One unit test: text_format reaches results in the encoded config when set, and is absent when it is not. The existing "defaults send only the audio format" test already covers a config with no results.

ruff check, ruff format --check, ty check and the unit suite (751 passed, 2 skipped) are green locally.

Draft until the launch is live and this has been reviewed.


Run Proof on this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

stream_websocket (sync and async) takes text_format, and ASRResults has the
field, so a transcribe-stream-2 session can choose spoken or written numbers
and times. It is sent only when set: transcribe-stream-1 refuses the field,
null included. transcribe-stream-1 stays the default model.
@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/fishaudio/resources/asr.py 100.00% <100.00%> (ø)
src/fishaudio/types/__init__.py 100.00% <ø> (ø)
src/fishaudio/types/asr_realtime.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…be configure refusal

stream_websocket(text_format=...) now checks the value as ASRResults does, so
a typo such as "Written" raises before the connection opens instead of being
sent. The ASRResults docstring now says what transcribe-stream-1 does with the
field at session start (invalid_config ends the session) and in a mid-session
configure (configured with ok False, session goes on).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant