Skip to content

Add Speech Diarization + ASR (asr_diarize) - #22

Merged
wannaphong merged 1 commit into
mainfrom
add-diarize
Sep 14, 2026
Merged

wannaphong merged 1 commit into
mainfrom
add-diarize

Conversation

@wannaphong

Copy link
Copy Markdown
Member

Add Speech Diarization + ASR (asr_diarize) by Sherpa-ONNX Diarization

Functions

Speech Diarization (Who Spoke When)

Detect speaker turns and timestamps using ONNX:

from pythaiasr import diarize

# Identify who spoke when
segments = diarize("meeting.wav")
for seg in segments:
    print(f"[{seg['start']:.2f}s - {seg['end']:.2f}s] {seg['speaker']}")

Speech Diarization + ASR (asr_diarize)

Detect speakers and transcribe each speaker turn with ASR:

from pythaiasr import asr_diarize

# Attributed transcription per speaker
turns = asr_diarize("meeting.wav", asr_model="typhoon_asr")
for turn in turns:
    print(f"[{turn['start']:.2f}s - {turn['end']:.2f}s] {turn['speaker']}: {turn['text']}")

See examples/diarize_example.py

============================================================
1. Speech Diarization (Who Spoke When)
============================================================
Processing: examples/../tests/test-diarize.wav ...
[  0.17s ->   1.87s] SPEAKER_02
[  1.97s ->   4.30s] SPEAKER_01
[  4.83s ->   6.49s] SPEAKER_02
[  6.78s ->   8.36s] SPEAKER_01

============================================================
2. Diarization + Speech Recognition (ASR Diarize)
============================================================
Transcribing turns with Typhoon ASR: examples/../tests/test-diarize.wav ...
[  0.17s ->   1.87s] SPEAKER_02: สวัสดีชาวโลกทุกท่าน
[  1.97s ->   4.30s] SPEAKER_01: แล้วระบบนี้ทํางานอย่างไร
[  4.83s ->   6.49s] SPEAKER_02: ใช้ปัญญาประดิษฐ์ในการทดสอบ
[  6.78s ->   8.36s] SPEAKER_01: ใช้งานได้ดีทีเดียว

@wannaphong
wannaphong merged commit 76a726b into main Sep 14, 2026
5 checks passed
wannaphong added a commit that referenced this pull request Sep 14, 2026
- Add Speech Diarization + ASR (asr_diarize) #22
- Add timestamp #23
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