Skip to content

feat(asr): send the Pro model options from transcribe() - #209

Merged
lumpinif merged 2 commits into
mainfrom
feat/asr-pro-options
Dec 3, 2026
Merged

lumpinif merged 2 commits into
mainfrom
feat/asr-pro-options

Conversation

@lumpinif

@lumpinif lumpinif commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

transcribe-2-pro puts speaker markers (<|speaker:0|>) and event cues ([laughter]) in text by default, and the API has fields to control them and more. asr.transcribe() could not send any of them, so getting a plain transcript meant calling POST /v1/asr directly.

Before

  • transcribe() sent only audio, language and ignore_timestamps.
  • On transcribe-2-pro, the transcript always had speaker markers and cues.
  • There was no way to send speaker-count hints, spoken numbers, verbatim or key terms.

After

  • transcribe() (sync and async) takes tag_audio_events, diarize (True, False or "auto"), num_speakers, min_speakers, max_speakers, text_format ("written" or "spoken"), verbatim and keyterms.
  • Each option is sent typed as the API requires: booleans, integers, and an array of strings for keyterms.
  • An option left as None is not sent, so existing calls send exactly the same bytes as before.
  • Values and combinations are checked by the API, which ignores fields a model does not use. The SDK only refuses keyterms that is not a list-like sequence of terms (a single string, or a dict), which would otherwise be sent as characters or keys.
  • New types: ASRDiarize, ASRTextFormat.
  • README and docstrings: a "plain transcript on transcribe-2-pro" example.
result = client.asr.transcribe(
    audio=audio, model="transcribe-2-pro", diarize=False, tag_audio_events=False
)

Verification

  • Unit tests check the request body on the wire for each option, sync and async. Without options, the body is byte-for-byte as on main.
  • Python 3.9 + httpx-ws 0.7.2 and 3.12 + httpx-ws 0.10.0; ruff, format and ty pass.
  • Live on the API with transcribe-2-pro:
    • diarize=False + tag_audio_events=False returns text with no markers or cues;
    • text_format="spoken" writes "three hundred dollars";
    • verbatim=False removes fillers;
    • keyterms=["Kubernetes"] fixes a misheard term;
    • speaker-count hints are accepted;
    • invalid combinations return a readable 400;
    • transcribe-1-pro and transcribe-1 ignore the fields they do not use.

Not covered

  • The realtime API (stream_websocket) is unchanged; it already has diarize and tag_audio_events.
  • The SDK does not check model/option combinations or limits; the API does.
  • With keyterms, the API may not follow verbatim=False or text_format="spoken". That is API behaviour; the keyterms docstring says so.

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

The SDK points callers to transcribe-2-pro, which by default puts speaker
markers (<|speaker:0|>) and event cues ([laughter]) in text, but
transcribe() could not send the fields that control them, so a caller who
wanted the plain transcript had to call POST /v1/asr directly.

transcribe() (sync and async) now takes tag_audio_events, diarize (True,
False or "auto"), num_speakers, min_speakers, max_speakers, text_format
("written" or "spoken"), verbatim and keyterms. They go in the MessagePack
body typed as the API requires: booleans, integers, a boolean or "auto"
for diarize, and an array of strings for keyterms. An option left as None
is not sent, so a request without options is byte for byte as before. The
API checks values and combinations itself and ignores fields a model does
not use; the SDK only refuses keyterms given as a string, which would
otherwise be sent as one term per character.
…choing them

list() turned a dict into its keys and a string into its characters, and
the API accepts either. keyterms must now be a sequence that is not a str,
bytes or mapping (a list, a tuple or another Sequence); anything else
raises TypeError before sending. The message names the type and shows the
right form, but not the value: a glossary can hold customer or product
names, and exceptions get logged. The terms themselves stay the API's to
check. The README and docstrings say that verbatim=False asks the model to
leave out fillers and false starts.
Copilot AI lite review requested due to automatic review settings December 3, 2026 04:16
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-12-03T04:16:58.111007Z
We couldn’t complete this review. Comment @codex review to try again.
2fdf084 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4b603ffc-abf1-4a28-b27f-c7f51619cb8a
Commits

Reviewing files that changed from the base of the PR and between 8784f88 and 2fdf084.

Files selected for processing: 5

  • README.md
  • src/fishaudio/resources/asr.py
  • src/fishaudio/types/__init__.py
  • src/fishaudio/types/asr.py
  • tests/unit/test_asr.py
  • 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 3, 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% <100.00%> (ø)
src/fishaudio/types/asr.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the added ASR options, validation, serialization, exports, tests, and documentation.

No open issues 🎉

What changed in this PR

Adds Pro-model transcription options to synchronous and asynchronous asr.transcribe() calls while preserving existing request bodies when options are unset.

Changes:

  • Adds typed options for diarization, event tagging, speaker counts, formatting, verbatim output, and keyterms.
  • Exports new ASR option types and updates tests and documentation.
File Description
tests/​unit/​test_asr.py Tests synchronous and asynchronous option serialization and validation.
src/​fishaudio/​types/​asr.py Defines the new ASR diarization and text-format types.
src/​fishaudio/​types/​__init__.py Exports the new ASR option types.
src/​fishaudio/​resources/​asr.py Adds validation and request serialization for transcription options.
README.md Documents plain Pro-model transcripts and supported transcription options.

Review effort: Lite

@lumpinif
lumpinif merged commit 65846ae into main Dec 3, 2026
36 of 40 checks passed
@lumpinif
lumpinif deleted the feat/asr-pro-options branch December 3, 2026 04:33
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.

2 participants