voice gender classifier
Overview
Highlights
- Efficient binary classification of speaker gender from audio
- Low-latency integration for real-time voice processing pipelines
- Permissive MIT license for flexible commercial deployment
- Reduces overhead compared to full speech recognition models
Usage
# Install Hugging Face transformers
pip install transformers torch
# Load model with transformers
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("JaesungHuh/voice-gender-classifier")
tokenizer = AutoTokenizer.from_pretrained("JaesungHuh/voice-gender-classifier")
Hugging Face Download
We recommend downloading the model via the Hugging Face CLI or Hub SDK.
Guidance:Before downloading, install huggingface_hub with:
pip install -U huggingface_hub
CLI Download
Download the full repository
huggingface-cli download JaesungHuh/voice-gender-classifier
Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download JaesungHuh/voice-gender-classifier config.json --local-dir ./dir
See the official docs for more CLI options
SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('JaesungHuh/voice-gender-classifier')
Git Download
Make sure git-lfs is installed first
git lfs install
git clone https://huggingface.co/JaesungHuh/voice-gender-classifier
To skip LFS large-file downloads, use:
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/JaesungHuh/voice-gender-classifier
Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.
PyTorch / Transformers Usage
Install Transformers
pip install -U transformers torch
Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('JaesungHuh/voice-gender-classifier')
tokenizer = AutoTokenizer.from_pretrained('JaesungHuh/voice-gender-classifier')
Full Documentation
---
tags:
- pytorch_model_hub_mixin
- model_hub_mixin
- gender-classification
- VoxCeleb
license: mit
datasets:
- ProgramComputer/voxceleb
pipeline_tag: audio-classification
---
Voice gender classifier
- This repo contains the inference code to use pretrained human voice gender classifier.
- You could also try 🤗Huggingface online demo.
Installation
First, clone the original github repositorygit clone https://github.com/JaesungHuh/voice-gender-classifier.gitand install the packages via pip.
cd voice-gender-classifier
pip install -r requirements.txtUsage
import torch
from model import ECAPA_gender
You could directly download the model from the huggingface model hub
model = ECAPA_gender.from_pretrained("JaesungHuh/voice-gender-classifier")
model.eval()
If you are using gpu ....
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
Load the audio file and use predict function to directly get the output
example_file = "data/00001.wav"
with torch.no_grad():
output = model.predict(example_file, device=device)
print("Gender : ", output)Pretrained weights
For those who need pretrained weights, please download it in hereTraining details
State-of-the-art speaker verification model already produces good representation of the speaker's gender.I used the pretrained ECAPA-TDNN from TaoRuijie's repository, added one linear layer to make two-class classifier, and finetuned the model with the VoxCeleb2 dev set.
The model achieved 98.7% accuracy on the VoxCeleb1 identification test split.
Caveat
I would like to note the training dataset I've used for this model (VoxCeleb) may not represent the global human population. Please be careful of unintended biases when using this model.Reference
- I modified the model architecture from TaoRuijie's repository.
- For more details about ECAPA-TDNN, check the paper.