voice gender classifier

ProviderJaesungHuh
Categoryaudio-classification
Licensemit
Downloads330.0K
Stars0

Overview

The Voice Gender Classifier is a specialized audio classification model designed to determine the perceived gender of a speaker from raw audio input. For developers building accessibility tools, automated user profiling, or voice-activated interfaces, this model provides a lightweight way to categorize vocal characteristics without requiring full speech-to-text transcription. It integrates easily into audio processing pipelines, serving as a pre-processing step to route requests to gender-specific voice synthesis or analysis modules. Compared to general-purpose audio models, this focused classifier offers lower latency and reduced computational overhead for this specific binary classification task.

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
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# 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:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

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)

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

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 Download
git lfs install
git clone https://huggingface.co/JaesungHuh/voice-gender-classifier

To skip LFS large-file downloads, use:

Skip LFS
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

Install Transformers
pip install -U transformers torch

Load the model and run inference

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

来源: HuggingFace

---
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.

Installation

First, clone the original github repository
code
git clone https://github.com/JaesungHuh/voice-gender-classifier.git

and install the packages via pip.

code
cd voice-gender-classifier
pip install -r requirements.txt

Usage

code
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 here

Training 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.
Join our Telegram