Repository navigation
Conversation
Add aai.Diarizer and aai.AsyncDiarizer for POST /v1/diarize on diarization.assemblyai.com (US/EU data-residency hosts via settings.diarization_base_url). diarize(audio, transcript=None, config=None, *, content_type=None) posts a buffered multipart body (Content-Length is required by the API) with the audio, an optional JSON transcript (a SyncTranscriptResponse, a dict with words, or a list of words) and an optional DiarizationConfig. Omitting the transcript runs segments-only mode. The audio Content-Type is inferred from the extension (shared with Dictation), audio/pcm when sample_rate/channels are set, and can be overridden. problem+json errors map to DiarizationError through the sync API's shared parser. Bumps the version to 1.11.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a client for the standalone Diarization API (
POST /v1/diarize), which labels the speakers in an audio file.What's added
aai.Diarizerandaai.AsyncDiarizerwithdiarize(audio, transcript=None, config=None, *, content_type=None). They follow the layout of the TTS and Dictation clients.SyncTranscriptResponse(requested withtimestamps=True), a dict withwords, or a list of words. Each word comes back with a speaker and the words are grouped into utterances.transcriptto get speaker turns (segments) andspeakers. Diarization can then run in parallel with transcription.DiarizationConfig(sample_rate,channels,language_code; unknown fields are rejected) andDiarizationResponse(words,utterances,segments,speakers,audio_duration_ms,session_id,request_time_ms).DiarizationErroris built by the existing problem+json mapper (sync/v1/api.py::_error_from_response). It carriesstatus_code,error_codeandretry_after.diarization_base_urldefaults tohttps://diarization.assemblyai.com. Set it tohttps://diarization.us.assemblyai.comorhttps://diarization.eu.assemblyai.comto keep requests in that data zone.diarization_http_timeoutdefaults to 330 s: the server's 300 s inference timeout plus its 10 s queue wait, with margin.sample_rate/channelssendsaudio/pcm.content_type=overrides both. The body is a buffered multipart upload soContent-Lengthis always set; the API returns 411 without it.CLAUDE.mdentries;Testing
pytest -n auto -q: 1076 passed, 42 of them new (tests/unit/test_diarization.py,test_diarization_async.py). The new tests cover:api_key=.py311-latest,py312-latest,py311-httpx0.22,py311-httpx0.24,py311-pydantic1.10andpy311-websockets11.0all pass. The legacy envs caught two real bugs, both fixed:strmultipart parts;ruff format --checkandruff checkpass, andcheck_api_docs.pyreports "API reference OK".Notes for review
Diarizer/AsyncDiarizer/Diarization*. Happy to rename to match house style.tort.wordsrather than{"words": t.words}.dictation.v1._base, the same pattern as Dictation importing the sync error parser.The API itself is live in us-west-2 and eu-west-1. Docs: AssemblyAI/assemblyai-docs#584 (in review; its samples will use this client).
🤖 Generated with Claude Code