Skip to content

feat(vad): FSMN-VAD backend (CoreML)#653

Open
Alex-Wengg wants to merge 8 commits into
mainfrom
feat/fsmn-vad-coreml
Open

feat(vad): FSMN-VAD backend (CoreML)#653
Alex-Wengg wants to merge 8 commits into
mainfrom
feat/fsmn-vad-coreml

Conversation

@Alex-Wengg

Copy link
Copy Markdown
Member

Summary

Adds FSMN-VAD (FunASR, ~5.2M) as a CoreML voice-activity-detection backend. Model: FluidInference/fsmn-vad-coreml.

Pipeline

waveform → [Preprocessor fp32/CPU] → 400-d features (fbank80 + LFR m=5,n=1)
        → [FSMN fp16/ANE, enumerated 512..3072] → [1,T,248] frame scores (col 0 = silence prob)
        → host decision → speech segments [start_ms, end_ms]

The decision ports FunASR's FsmnVADStreaming: per-frame speech if silence_prob ≤ 0.2, a 20-frame sliding-window hysteresis (sil→speech / speech→sil at 15), silence→endpoint after max_end_silence (800 ms), lookback/lookahead, and max_single_segment (60 s). Audio > ~30 s is processed in chunks; per-frame silence probs are concatenated and the decision runs once.

(RangeDim breaks the FSMN's dilated conv on the BNNS path, so the scorer uses fixed enumerated buckets and the host chunks long audio.)

Changes

  • ModelNames: fsmnVad Repo + FsmnVad registry
  • Sources/FluidAudio/VAD/Fsmn/: FsmnVadModels, FsmnVadManager (+ FsmnVadSegment)
  • CLI: fsmn-vad-segment

Verification

On a 20 s clip: [120, 19960] vs FunASR [70, 19980] — boundaries within ~50 ms. 0.04 s, 0.056 GB peak.

Notes

  • Alternative to FluidAudio's existing silero-vad.
  • The decision is faithful-to-behavior (matches FunASR within ~50 ms), not a bit-exact port of the full streaming state machine.

CoreML FSMN-VAD from FluidInference/fsmn-vad-coreml: 2-stage (fbank80+LFR preprocessor
fp32/CPU -> FSMN scorer fp16/ANE enumerated [512..3072] -> [1,T,248] scores) + a host
decision (port of FunASR FsmnVADStreaming: speech if silence_prob<=0.2, 20-frame window
hysteresis at 15, max_end_silence 800ms, lookback/lookahead, max_single_segment 60s) ->
[start_ms,end_ms]. Long audio chunked at ~30s; silence probs concatenated, decision once.

- ModelNames: fsmnVad Repo + FsmnVad registry
- VAD/Fsmn/: FsmnVadModels, FsmnVadManager (+ FsmnVadSegment)
- CLI: fsmn-vad-segment
Verified vs FunASR on 20s clip: [120,19960] vs [70,19980] (~50ms). Alternative to silero-vad.
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Parakeet EOU Benchmark Results ✅

Status: Benchmark passed
Chunk Size: 320ms
Files Tested: 100/100

Performance Metrics

Metric Value Description
WER (Avg) 7.03% Average Word Error Rate
WER (Med) 4.17% Median Word Error Rate
RTFx 8.21x Real-time factor (higher = faster)
Total Audio 470.6s Total audio duration processed
Total Time 63.0s Total processing time

Streaming Metrics

Metric Value Description
Avg Chunk Time 0.063s Average chunk processing time
Max Chunk Time 0.126s Maximum chunk processing time
EOU Detections 0 Total End-of-Utterance detections

Test runtime: 1m12s • 06/01/2026, 11:12 AM EST

RTFx = Real-Time Factor (higher is better) • Processing includes: Model inference, audio preprocessing, state management, and file I/O

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

PocketTTS Smoke Test ✅

Check Result
Build
Model download
Model load
Synthesis pipeline
Output WAV ✅ (146.3 KB)

Runtime: 0m26s

Note: PocketTTS uses CoreML MLState (macOS 15) KV cache + Mimi streaming state. CI VM lacks physical GPU — audio quality and performance may differ from Apple Silicon.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

VAD Benchmark Results

Performance Comparison

Dataset Accuracy Precision Recall F1-Score RTFx Files
MUSAN 92.0% 86.2% 100.0% 92.6% 563.1x faster 50
VOiCES 92.0% 86.2% 100.0% 92.6% 608.9x faster 50

Dataset Details

  • MUSAN: Music, Speech, and Noise dataset - standard VAD evaluation
  • VOiCES: Voices Obscured in Complex Environmental Settings - tests robustness in real-world conditions

✅: Average F1-Score above 70%

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Speaker Diarization Benchmark Results

Speaker Diarization Performance

Evaluating "who spoke when" detection accuracy

Metric Value Target Status Description
DER 15.1% <30% Diarization Error Rate (lower is better)
JER 24.9% <25% Jaccard Error Rate
RTFx 28.46x >1.0x Real-Time Factor (higher is faster)

Diarization Pipeline Timing Breakdown

Time spent in each stage of speaker diarization

Stage Time (s) % Description
Model Download 8.949 24.3 Fetching diarization models
Model Compile 3.835 10.4 CoreML compilation
Audio Load 0.067 0.2 Loading audio file
Segmentation 11.057 30.0 Detecting speech regions
Embedding 18.429 50.0 Extracting speaker voices
Clustering 7.372 20.0 Grouping same speakers
Total 36.875 100 Full pipeline

Speaker Diarization Research Comparison

Research baselines typically achieve 18-30% DER on standard datasets

Method DER Notes
FluidAudio 15.1% On-device CoreML
Research baseline 18-30% Standard dataset performance

Note: RTFx shown above is from GitHub Actions runner. On Apple Silicon with ANE:

  • M2 MacBook Air (2022): Runs at 150 RTFx real-time
  • Performance scales with Apple Neural Engine capabilities

🎯 Speaker Diarization Test • AMI Corpus ES2004a • 1049.0s meeting audio • 36.9s diarization time • Test runtime: 2m 30s • 06/01/2026, 11:12 AM EST

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Sortformer High-Latency Benchmark Results

ES2004a Performance (30.4s latency config)

Metric Value Target Status
DER 30.3% <35%
Miss Rate 28.2% - -
False Alarm 0.9% - -
Speaker Error 1.2% - -
RTFx 9.9x >1.0x
Speakers 4/4 - -

Sortformer High-Latency • ES2004a • Runtime: 4m 0s • 2026-06-01T15:13:11.849Z

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

ASR Benchmark Results ✅

Status: All benchmarks passed

Parakeet v3 (multilingual)

Dataset WER Avg WER Med RTFx Status
test-clean 0.57% 0.00% 5.27x
test-other 1.96% 0.00% 3.24x

Parakeet v2 (English-optimized)

Dataset WER Avg WER Med RTFx Status
test-clean 0.80% 0.00% 4.94x
test-other 1.00% 0.00% 2.97x

Streaming (v3)

Metric Value Description
WER 0.00% Word Error Rate in streaming mode
RTFx 0.57x Streaming real-time factor
Avg Chunk Time 1.595s Average time to process each chunk
Max Chunk Time 1.898s Maximum chunk processing time
First Token 1.908s Latency to first transcription token
Total Chunks 31 Number of chunks processed

Streaming (v2)

Metric Value Description
WER 0.00% Word Error Rate in streaming mode
RTFx 0.45x Streaming real-time factor
Avg Chunk Time 1.962s Average time to process each chunk
Max Chunk Time 2.916s Maximum chunk processing time
First Token 1.971s Latency to first transcription token
Total Chunks 31 Number of chunks processed

Streaming tests use 5 files with 0.5s chunks to simulate real-time audio streaming

25 files per dataset • Test runtime: 6m26s • 06/01/2026, 11:09 AM EST

RTFx = Real-Time Factor (higher is better) • Calculated as: Total audio duration ÷ Total processing time
Processing time includes: Model inference on Apple Neural Engine, audio preprocessing, state resets between files, token-to-text conversion, and file I/O
Example: RTFx of 2.0x means 10 seconds of audio processed in 5 seconds (2x faster than real-time)

Expected RTFx Performance on Physical M1 Hardware:

• M1 Mac: ~28x (clean), ~25x (other)
• CI shows ~0.5-3x due to virtualization limitations

Testing methodology follows HuggingFace Open ASR Leaderboard

Add --backend fsmn to vad-benchmark (same labeled dataset + per-clip metric as
silero). On mini50: FSMN-VAD F1 98.0% (P 96.2/R 100) vs silero 84.7% (P 73.5/R 100),
RTFx 640x. Update Benchmarks.md with the apples-to-apples comparison.
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Qwen3-ASR int8 Smoke Test ✅

Check Result
Build
Model download
Model load
Transcription pipeline
Decoder size 571 MB (vs 1.1 GB f32)

Performance Metrics

Metric CI Value Expected on Apple Silicon
Median RTFx 0.05x ~2.5x
Overall RTFx 0.05x ~2.5x

Runtime: 4m23s

Note: CI VM lacks physical GPU — CoreML MLState (macOS 15) KV cache produces degraded results on virtualized runners. On Apple Silicon: ~1.3% WER / 2.5x RTFx.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Offline VBx Pipeline Results

Speaker Diarization Performance (VBx Batch Mode)

Optimal clustering with Hungarian algorithm for maximum accuracy

Metric Value Target Status Description
DER 10.4% <20% Diarization Error Rate (lower is better)
RTFx 7.71x >1.0x Real-Time Factor (higher is faster)

Offline VBx Pipeline Timing Breakdown

Time spent in each stage of batch diarization

Stage Time (s) % Description
Model Download 16.155 11.9 Fetching diarization models
Model Compile 6.924 5.1 CoreML compilation
Audio Load 0.116 0.1 Loading audio file
Segmentation 38.084 28.0 VAD + speech detection
Embedding 135.782 99.8 Speaker embedding extraction
Clustering (VBx) 0.124 0.1 Hungarian algorithm + VBx clustering
Total 136.119 100 Full VBx pipeline

Speaker Diarization Research Comparison

Offline VBx achieves competitive accuracy with batch processing

Method DER Mode Description
FluidAudio (Offline) 10.4% VBx Batch On-device CoreML with optimal clustering
FluidAudio (Streaming) 17.7% Chunk-based First-occurrence speaker mapping
Research baseline 18-30% Various Standard dataset performance

Pipeline Details:

  • Mode: Offline VBx with Hungarian algorithm for optimal speaker-to-cluster assignment
  • Segmentation: VAD-based voice activity detection
  • Embeddings: WeSpeaker-compatible speaker embeddings
  • Clustering: PowerSet with VBx refinement
  • Accuracy: Higher than streaming due to optimal post-hoc mapping

🎯 Offline VBx Test • AMI Corpus ES2004a • 1049.0s meeting audio • 174.0s processing • Test runtime: 4m 34s • 06/01/2026, 11:24 AM EST

… 69.8% specificity)

Full FluidInference/musan noise set (774 clips): FSMN-VAD rejects 81.9% of noise
as non-speech (18.1% FP) vs silero 69.8% (30.2% FP) — 12pp fewer false positives.
Complements the balanced mini50 F1 (98.0% vs 84.7%).
The Lab41/VOiCES-subset repo now ships audio inside VOiCES_90_*.tar archives
(deeply nested) rather than loose clean/ + noisy/ wavs, so the downloader
silently produced 0 files. Extract every tar and classify each wav by the
noise tag in its filename (-none- = clean, else noisy); error if a clone
yields no wavs (layout changed again).

loadVoicesSubset ignored --all-files: count == -1 was hard-coded to 25 speech
samples (12 clean + 12 noisy), so --all-files ran only ~49 files. Now -1 loads
every VOiCES clip (908) and balances the MUSAN negatives to the speech count
(subject to locally available noise).

Verified: download yields 227 clean + 681 noisy; --all-files runs 933 files
(908 speech + 25 noise), F1 99.9%, ~1334x RTFx on M5 Pro.
# Conflicts:
#	Sources/FluidAudio/ModelNames.swift
- FSMN backend leaked memory on long files (autoreleased MLMultiArrays + AVAudio
  buffers accumulated across chunks/files -> ~8GB RSS, OOM on full MUSAN). Wrap
  per-chunk scoring and per-file resampling in autoreleasepool; RSS now ~240MB.
- Mark FSMN-VAD as beta/experimental in docs and CLI: on a balanced full-MUSAN
  set it has high recall but over-triggers on music (low precision), so silero-vad
  stays the recommended default. Drop the non-representative head-to-head tables.
- Persist FSMN benchmark metrics to fsmn_vad_results.json (release logs info to
  os_log only).
Keep the code changes from 572178b (FSMN memory fix, CLI beta warning,
fsmn_vad_results.json output); drop the Benchmarks.md edits per request.
@LemonCANDY42

LemonCANDY42 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for adding the FSMN-VAD backend. I’m curious whether there are any existing benchmark comparisons between Ten-VAD and FSMN-VAD for this use case, especially around VAD accuracy and streaming performance/latency. If you’ve already looked at Ten-VAD, I’d be interested to know how it compares as a CoreML VAD candidate.

@Alex-Wengg

Copy link
Copy Markdown
Member Author

@LemonCANDY42 i have not had the time to benchmark. i am too sure how it performs compared to tad but i think vad silero is still the bset

@LemonCANDY42

Copy link
Copy Markdown
Contributor

@LemonCANDY42 i have not had the time to benchmark. i am too sure how it performs compared to tad but i think vad silero is still the bset

Got it, thanks.

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.

2 participants