voice gender classifier

提供商JaesungHuh
分类audio-classification
许可证mit
下载量330.0K
星标0

简介

这是一个轻量级的音频分类模型,专注于通过语音特征自动识别说话者的性别。对于需要处理大量语音数据的开发者来说,它能快速实现性别标签的自动化标注,而无需人工听写。该模型上手门槛极低,非常适合集成到用户画像分析、智能客服分流或语音交互系统的预处理环节中。相比于复杂的全能型语音大模型,它在特定任务上运行更高效,是构建语音分析管线中一个实用且低开销的组件。

核心亮点

  • 快速识别语音性别,实现自动化标签标注
  • 轻量级设计,部署成本低且推理速度快
  • 适用于用户画像分析与智能语音分流场景
  • 采用 MIT 许可,对商业集成非常友好

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("JaesungHuh/voice-gender-classifier")
tokenizer = AutoTokenizer.from_pretrained("JaesungHuh/voice-gender-classifier")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download JaesungHuh/voice-gender-classifier

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download JaesungHuh/voice-gender-classifier config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('JaesungHuh/voice-gender-classifier')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/JaesungHuh/voice-gender-classifier

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/JaesungHuh/voice-gender-classifier

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('JaesungHuh/voice-gender-classifier')
tokenizer = AutoTokenizer.from_pretrained('JaesungHuh/voice-gender-classifier')

完整文档

来源: 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.