Python · Resonance · Updated September 13, 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.
python -m pip install https://oruk.ai/sdk/oruk-0.2.15-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"""Python 3.10+ and the Oruk SDK from https://oruk.ai/docs/sdks.
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.
Orukeet also supports speaker labels
For short English recordings, the hosted Orukeet preview supports diarize=True with client.transcribe and model="oruk-orukeet". It accepts up to 60 seconds and 4 MiB per complete request. Emotion detection is a separate optional flag; this guide’s Resonance analysis response is not the Orukeet response format.
Orukeet speaker diarization has an additional usage rate drawn from the Orukeet allowance. Read the Orukeet request and response contract, current pricing, and temporary audio retention terms before choosing the workflow.
Read a speaker turn
| Field | Meaning |
|---|---|
| diarized | Whether the result is organized into speaker turns. |
| speakers | Speaker labels in order of first appearance. |
| segments[].speaker | The local speaker label, such as speaker_0. |
| segments[].start / end | Turn boundaries, measured in seconds from the recording start. |
| segments[].text | Transcript for the turn when using analysis or transcriptions. |
| segments[].emotions / styles | Model scores for the vocal expression of this turn. |
| usage.audio_seconds | Measured 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
For a complete implementation, build the local call-review panel: start with licensed public audio and a saved response, replay speaker turns, then connect your own SDK output.
- Store your recording identifier alongside the response request ID and timed segments.
- Show each turn’s speaker label and transcript. Let a reviewer replay the original start/end interval.
- Use several emotion and style scores to select passages for review. Validate selection thresholds on representative calls or interviews.
- 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
For the Resonance example in this guide, diarization is included in the plan’s other-model allowance. A minute of input consumes one minute of that allowance; the number of speaker turns does not multiply the allowance. Older metered accounts retain their documented add-on rate. Read current pricing.
This example uses Resonance file analysis. An unsupported model on these file-analysis endpoints 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. Speaker labeling adds a diarization processing step; review the processing terms on the security page for your deployment.