Core ML conversion of
FireRedVAD Stream-VAD for real-time voice activity detection on Apple platforms (iOS 16+ / macOS 13+). Converted from the original PyTorch model by
FireRedTeam/FireRedVAD.
Converted from PyTorch using
coremltools via the export script in
FireRedASR2S. The Stream-VAD variant was selected for its causal (no lookahead) property, making it suitable for real-time streaming applications.
1import CoreML
2
3// Load model
4let model = try FireRedVAD(configuration: .init())
5
6// Initialize caches (8 layers x [1, 128, 19])
7var caches = (0..<8).map { _ in
8 try! MLMultiArray(shape: [1, 128, 19], dataType: .float32)
9}
10
11// Process audio frame by frame
12let input = FireRedVADInput(
13 feat: fbankFeatures, // [1, T, 80]
14 cache_0: caches[0], cache_1: caches[1],
15 cache_2: caches[2], cache_3: caches[3],
16 cache_4: caches[4], cache_5: caches[5],
17 cache_6: caches[6], cache_7: caches[7]
18)
19let output = try model.prediction(input: input)
20let speechProb = output.probs // [1, T, 1]
21
22// Update caches for next frame
23caches = [
24 output.new_cache_0, output.new_cache_1,
25 output.new_cache_2, output.new_cache_3,
26 output.new_cache_4, output.new_cache_5,
27 output.new_cache_6, output.new_cache_7
28]
For a complete implementation with feature extraction, CMVN normalization, and speech state machine, see
FireRedASRKit.
Apache 2.0, following the original
FireRedVAD license.