Skip to content

Explore oruk

Python · Resonance · September 6, 2026

Speaker diarization with transcription and emotion in Python

Diarization divides a recording into speaker turns. With diarize=True, Resonance returns a transcript, emotion, and speaking-style scores for each turn. The labels identify voices within that response; they do not tell you which speaker is the customer, interviewer, or agent.

Install and run

Use Python 3.10 or later and the versioned SDK below. Choose an English recording in WAV, FLAC, MP3, M4A, OGG, or WebM, at most 30 MB and 60 minutes. Keep your API key in the environment.

Terminal
python -m pip install https://oruk.ai/sdk/oruk-0.2.4-py3-none-any.whl
curl --fail -O https://oruk.ai/examples/diarize.py
# Set ORUK_API_KEY in your environment, then run:
python diarize.py recording.wav
diarize.py
"""Python 3.10+ and oruk SDK 0.2.4. Run: python diarize.py recording.wav."""
import json
import os
import sys
from oruk import Oruk

with Oruk(api_key=os.environ["ORUK_API_KEY"]) as client:
    result = client.analyze(
        sys.argv[1], model="oruk-resonance", diarize=True,
        # Set num_speakers=2 only when you know there are exactly two speakers.
    )

print(json.dumps(result, indent=2))
# Each result["segments"] entry has start/end, speaker, text, emotions and styles.
# speaker_0 and speaker_1 are local labels, not persistent identities or roles.
Download the complete example

Read a speaker turn

FieldMeaning
diarizedWhether the result is organized into speaker turns.
speakersSpeaker labels in order of first appearance.
segments[].speakerThe local speaker label, such as speaker_0.
segments[].start / endTurn boundaries, measured in seconds from the recording start.
segments[].textTranscript for the turn when using analysis or transcriptions.
segments[].emotions / stylesModel scores for the vocal expression of this turn.
usage.audio_secondsMeasured duration of the submitted recording.

Leave num_speakers unset to detect the speaker count. Supply an integer from one to 32 only when you know the count. To request emotion without a transcript, replace client.analyze with client.emotions; keep model="oruk-resonance" and diarize=True.

Build a review workflow

  1. Store your recording identifier alongside the response request ID and timed segments.
  2. Show each turn’s speaker label and transcript. Let a reviewer replay the original start/end interval.
  3. Use several emotion and style scores to select passages for review. Validate selection thresholds on representative calls or interviews.
  4. Assign known roles from your application’s participant data or a human review. Do not infer roles, identity, or job performance from a voice label alone.

Try the API on the public sample catalog before connecting customer recordings. These curated CREMA-D training examples demonstrate integration, not held-out accuracy or contact-center results. Preserve the source attribution and licenses.

Costs and failure cases

Diarization is included in current subscription plan minutes. A minute of input consumes one plan minute; the number of speaker turns does not multiply the allowance. Older metered accounts retain their documented add-on rate. Read current pricing.

File diarization requires Resonance. An unsupported model returns 400 diarization_unsupported; an unavailable diarizer returns 503 diarization_upstream_failed. Overlapping speech, very short turns, and similar voices can cause attribution errors. Check boundaries and label consistency on your own recordings before relying on speaker-level summaries. PyannoteAI performs the speaker pass as a subprocessor.