CremyX Diarize avatar

CremyX Diarize

Pricing

Pay per usage

Go to Apify Store
CremyX Diarize

CremyX Diarize

Speaker diarization with sherpa-onnx: returns speaker turns and can label an existing word-level transcript with speaker IDs.

Pricing

Pay per usage

Rating

0.0

(0)

Developer

Kevin Phạm

Kevin Phạm

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

2

Monthly active users

a day ago

Last modified

Categories

Share

cremyx-diarize

sherpa-onnx speaker diarization: ai nói, nói lúc nào. Thay cho việc bắt user cài sherpa-onnx + model trên máy.

  • Base image: node:22-bookworm-slim (sherpa-onnx chỉ có binary glibc, không chạy Alpine)
  • Model nướng sẵn: sherpa-onnx-pyannote-segmentation-3-0 + nemo_en_titanet_small.onnx

Input

{
"source": "kv:<storeId>/audio.wav", // hoặc https://… (mp4/m4a/mp3/wav đều được)
"transcript": "kv:<storeId>/transcript.json", // tuỳ chọn: transcript của cremyx-asr
"options": {
"num_speakers": null, // biết chắc số người nói thì điền (vd 2) → chính xác hơn nhiều
"cluster_threshold": 0.5, // dùng khi không biết số người; nhỏ hơn = tách nhiều người hơn
"min_duration_on": 0.3, // đoạn nói ngắn hơn (giây) thì bỏ
"min_duration_off": 0.5, // khoảng lặng đủ dài để tách 2 lượt nói
"threads": null // mặc định = số CPU (tối đa 8)
},
"output": { "signed_upload_url": null },
"cleanup": "on_success",
"callback": null
}

Nguồn luôn được convert về WAV 16 kHz mono trong actor, nên đưa mp4 vào cũng được.

Output

{
"status": "success",
"op": "diarize",
"artifacts": [
{ "name": "diarization", "kv_key": "diarization.json" },
{ "name": "transcript_speakers", "kv_key": "transcript-speakers.json" } // chỉ khi truyền "transcript"
],
"meta": {
"engine": "sherpa-onnx",
"duration_sec": 184.2,
"speaker_count": 2,
"speakers": [
{ "speaker": "SPEAKER_00", "turns": 24, "speech_ms": 96500 },
{ "speaker": "SPEAKER_01", "turns": 21, "speech_ms": 71200 }
],
"turn_count": 45,
"turns": [{ "start_ms": 1200, "end_ms": 5400, "speaker": "SPEAKER_00" }],
"transcript_labelled": true
}
}

speakers đã sắp theo tổng thời gian nói giảm dần — phần tử đầu là "người nói chính" của clip.

Gắn nhãn người nói vào transcript

Truyền thêm transcript (artifact transcript.json của cremyx-asr) thì actor trả về transcript-speakers.json: y hệt transcript gốc nhưng mỗi word và mỗi segment có thêm trường speaker. Nhãn được gán theo lượt nói chồng lấn nhiều nhất về thời gian.

{ "id": 0, "text": "Xin", "startMs": 120, "endMs": 310, "confidence": 0.93, "speaker": "SPEAKER_00" }

Mẹo dùng

  • Biết trước số người nói (podcast 2 người, phỏng vấn 1-1) → luôn set num_speakers. Đây là yếu tố ảnh hưởng chất lượng lớn nhất.
  • Nhiều người nói chồng nhau: diarization đưa mỗi thời điểm về một người duy nhất, không tách overlap.
  • Nhạc nền lớn làm giảm độ chính xác — nếu có track voice riêng thì dùng track đó.

Ví dụ nối chuỗi

const wav = await tools.mediaTools({ op: 'audio16k', source: videoUrl });
const asr = await tools.asr({ source: wav.kv('audio') });
const diar = await tools.diarize({
source: wav.kv('audio'),
transcript: asr.kv('transcript'),
options: { num_speakers: 2 },
});
console.log(diar.meta.speakers);

Shard window (v2)

Hỗ trợ options.start_sec / duration_sec / overlap_sec giống cremyx-asr; turn timestamp được offset về timeline gốc, turn trong đuôi overlap có _overlap: true.

Lưu ý: nhãn speaker (SPEAKER_00…) chỉ nhất quán trong một run. Cần speaker nhất quán cả video → chạy full file, hoặc shard dài (5–10 phút).

Memory mặc định run: 8 GB.