This model detects whether an audio signal contains a live human voice or a voicemail greeting. It's based on fine-tuned Wav2Vec2 and exported to ONNX format with FP16 precision for efficient inference.
Input: 2 seconds of audio at 16kHz (32,000 samples)
Output: Binary classification (live_human vs voicemail)
Model Size: ~605 MB (FP16 optimized)
Performance Metrics
Accuracy
Overall Accuracy: 72.73%
Live Human Detection: 100% (3/3)
Voicemail Detection: 62.5% (5/8)
Inference Speed
Average Inference Time: 705ms (CPU)
Memory Usage: ~1.6 GB during inference
Comparison with CNN Model
While the CNN model is faster (11ms) and smaller (18MB), the Wav2Vec2 model excels at:
Perfect live human detection (100% vs 67%)
Better on complex voicemail scenarios with realistic speech patterns
Use Cases
This model is ideal for:
📞 Automated phone systems that need to distinguish human responses from voicemail greetings
🎯 Call centers prioritizing live human connections
🤖 Voice assistants that need to detect voicemail before speaking
📊 Analytics systems tracking call connection rates
Best suited for: Applications where minimizing false positives on live humans is critical, and latency tolerance is >500ms.
Installation
pip install onnxruntime transformers numpy
Usage
Basic Inference
python
1import numpy as np
2import onnxruntime as ort
3from transformers import Wav2Vec2FeatureExtractor
45# Load the feature extractor (critical for proper preprocessing!)6feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(7"jakeBland/wav2vec-vm-finetune"8)910# Load ONNX model11session = ort.InferenceSession("model.onnx")1213# Prepare audio (2 seconds at 16kHz = 32,000 samples)14# audio_array should be a numpy array of shape (32000,)15inputs = feature_extractor(16 audio_array,17 sampling_rate=16000,18 return_tensors="np",19 padding=True,20)2122# Run inference23input_values = inputs.input_values.astype(np.float32)24outputs = session.run(None,{"input": input_values})25logits = outputs[0]2627# Get prediction28prediction_idx = np.argmax(logits, axis=-1)[0]29result ="voicemail"if prediction_idx ==1else"live_human"30print(f"Detection result: {result}")
With Audio File
python
1import librosa
2import numpy as np
34# Load audio file (mono, 16kHz)5audio, sr = librosa.load("audio.wav", sr=16000, mono=True)67# Take first 2 seconds (32,000 samples)8audio_segment = audio[:32000]910# Pad if shorter than 2 seconds11iflen(audio_segment)<32000:12 audio_segment = np.pad(audio_segment,(0,32000-len(audio_segment)))1314# Now use the inference code above
Important Implementation Notes
⚠️ Critical: Feature Extraction is Required
This model requires proper preprocessing using Wav2Vec2FeatureExtractor. Without normalization, accuracy drops from 73% to 36%.
The feature extractor applies:
Mean-std normalization (per-sample)
Padding configuration
Attention mask generation
DO NOT skip this step or implement custom normalization. Always use the official transformer's feature extractor.
Audio Requirements
Duration: Exactly 2 seconds (32,000 samples)
Sample Rate: 16kHz
Channels: Mono
Format: Float32 numpy array
Normalization: Via Wav2Vec2FeatureExtractor (do_normalize=True)
Model Input/Output
Input:
Name: input
Shape: [1, 32000]
Type: float32
Range: Normalized by feature extractor (mean=0, std=1)