gcw_6a3w2yXz/pyannote-voice-activity-detection
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

pyannote/voice-activity-detection - Ascend NPU Adapted

This is an Ascend NPU-adapted deployment for pyannote/voice-activity-detection (Voice Activity Detection pipeline wrapping segmentation).

  • Original VAD pipeline: https://huggingface.co/pyannote/voice-activity-detection
  • Segmentation weights: https://huggingface.co/pyannote/segmentation-3.0
  • Revision: e66f3d3b9eb0873085418a7b813d3b369bf160bb (segmentation-3.0)
  • Architecture: pyannote.audio.models.segmentation.PyanNet (SincNet stride 10, BiLSTM 4x128 bidirectional, linear 2x128) with 7-channel powerset output
  • Route: pyannote-vad (real audio file → frame probabilities → hysteresis binarization → speech segments)
  • Device: npu:0 with synchronized timing and CPU-NPU consistency validation
  • Task: Voice Activity Detection (speech vs non-speech timestamps, not ASR transcription)

NPU Device Proof

Model and tensors are explicitly placed on npu:0 and verified:

  • next(model.parameters()).device == npu:0
  • input waveform device == npu:0 (10s chunk [1,1,160000] and full 30s file chunked via Inference)
  • prob matrix device == npu:0 shape [1,589,7] (10s) and [1,1779,1] aggregated
  • torch.npu.synchronize() before/after timing

Synchronization uses torch.npu.synchronize() around each timed forward.

Consistency Validation

  • CPU vs NPU on identical 30s real audio (pyannote-audio/sample/sample.wav, 16000 Hz, mono, 30s, speech 6.7-30s):
    • Frame probabilities (10s chunk) max_abs_diff 0.00245, mean 0.00063, cosine 0.999999
    • VAD segments (onset 0.81 offset 0.48 min_on 0.055 min_off 0.097):
      • CPU: 4 segments [[6.73,7.20],[7.59,17.91],[18.03,21.51],[21.78,29.96]]
      • NPU: 4 segments [[6.73,7.20],[7.59,17.90],[18.03,21.51],[21.78,29.96]]
      • Segment count delta 0, max timestamp delta 0.0169s (<0.5s), coverage delta 0.00056 (<0.02), region IoU 0.999 (>0.95) => PASS
    • All finite, non-empty, monotonic timestamps

Performance (Ascend 910B)

  • Single 10s chunk: first compile ~10.0s, stable ~44 ms
  • Full 30s file (sliding 10s window step 1s, 1779 frames): first synchronized latency ~234 ms (after compile), stable ~58.5 ms (5 runs)
  • RTF mean 0.00195 (seconds of compute per second of audio), frames/s ~30387
  • Reported with torch.npu.synchronize() around each timed Inference call

Validated on Ascend 910 (2x NPU, 61 GiB free, torch 2.9.0, torch_npu 2.9.0.post1, CANN 8.5.1).

Usage

from pyannote.audio import Model
from pyannote.audio.core.inference import Inference
from pyannote.audio.utils.signal import Binarize
import soundfile as sf, torch, torch_npu, numpy as np

model = Model.from_pretrained("pyannote/segmentation-3.0")
model.to("npu:0")
inference = Inference(model, pre_aggregation_hook=lambda s: np.max(s, axis=-1, keepdims=True))
wave, sr = sf.read("audio.wav")  # 16kHz mono
file = {"waveform": torch.from_numpy(wave).float().unsqueeze(0), "sample_rate": sr}
scores = inference(file)  # (frames,1)
binarize = Binarize(onset=0.81, offset=0.48, min_duration_on=0.055, min_duration_off=0.097)
annotation = binarize(scores)
for seg, track in annotation.itertracks():
    print(seg.start, seg.end)

See inference.py for full synchronized example with device proof and 30s file.

Evidence

Agent Workflow NPU Device Call Model Result

Files

  • inference.py - NPU inference with device proof, consistency and perf
  • requirements.txt - dependencies
  • assets/*.png - xterm.js evidence screenshots

Limitations

  • VAD only (speech timestamps); not speaker diarization clustering or ASR
  • Validated on Ascend 910 with CANN 8.5.1; other variants may need recompilation
  • Segmentation-3.0 powerset 7 channels reduced to 1 via max for VAD