Downloads · 30 days
3
6% of all-time downloads
bdatdo0601/voicemail-detector-wav2vec2-onnx
voicemail-detector-wav2vec2-onnx is a machine learning model from bdatdo0601. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
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.
Downloads · 30 days
3
6% of all-time downloads
All-time downloads
53
Public
Repo size
635 MB
Likes
1
Public
Click a slice to open those files.
.data631 MB · 100%
From the Hugging Face model README
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.
While the CNN model is faster (11ms) and smaller (18MB), the Wav2Vec2 model excels at:
This model is ideal for:
Best suited for: Applications where minimizing false positives on live humans is critical, and latency tolerance is >500ms.
pip install onnxruntime transformers numpy
import numpy as np
import onnxruntime as ort
from transformers import Wav2Vec2FeatureExtractor
# Load the feature extractor (critical for proper preprocessing!)
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(
"jakeBland/wav2vec-vm-finetune"
)
# Load ONNX model
session = ort.InferenceSession("model.onnx")
# Prepare audio (2 seconds at 16kHz = 32,000 samples)
# audio_array should be a numpy array of shape (32000,)
inputs = feature_extractor(
audio_array,
sampling_rate=16000,
return_tensors="np",
padding=True,
)
# Run inference
input_values = inputs.input_values.astype(np.float32)
outputs = session.run(None, {"input": input_values})
logits = outputs[0]
# Get prediction
prediction_idx = np.argmax(logits, axis=-1)[0]
result = "voicemail" if prediction_idx == 1 else "live_human"
print(f"Detection result: {result}")
import librosa
import numpy as np
# Load audio file (mono, 16kHz)
audio, sr = librosa.load("audio.wav", sr=16000, mono=True)
# Take first 2 seconds (32,000 samples)
audio_segment = audio[:32000]
# Pad if shorter than 2 seconds
if len(audio_segment) < 32000:
audio_segment = np.pad(audio_segment, (0, 32000 - len(audio_segment)))
# Now use the inference code above
This model requires proper preprocessing using Wav2Vec2FeatureExtractor. Without normalization, accuracy drops from 73% to 36%.
The feature extractor applies:
DO NOT skip this step or implement custom normalization. Always use the official transformer's feature extractor.
Input:
input[1, 32000]float32Output:
logits[1, 2]float32[0: live_human, 1: voicemail]Tested on 11 audio samples:
| Category | Accuracy | Notes |
|---|---|---|
| Live Human | 100% (3/3) | Perfect detection |
| Voicemail | 62.5% (5/8) | Misses simple beeps |
| Overall | 72.73% (8/11) | Competitive performance |
Failed Cases:
If you use this model, please cite the original Wav2Vec2 voicemail detector:
@misc{wav2vec-vm-finetune,
author = {Jake Bland},
title = {Wav2Vec2 Voicemail Fine-tune},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/jakeBland/wav2vec-vm-finetune}
}
This model follows the license of the original jakeBland/wav2vec-vm-finetune model.
For questions or issues with this ONNX export, please open an issue in the repository.
Related Models: