Common Voice Gender Detection

提供商prithivMLmods
分类audio-classification
许可证apache-2.0
下载量2.8K
星标0

简介

Common Voice Gender Detection 是一个专注于音频性别识别的轻量级分类模型。它基于 Mozilla 的 Common Voice 开源数据集训练,能够快速分析语音片段并判断说话者的性别。对于需要处理大量语音数据的开发者来说,它可以作为预处理环节的自动化标签工具,无需复杂的音频工程知识即可快速部署。该模型适合集成在语音分析流水线中,与 Whisper 等语音转文字工具配合使用,为对话分析提供额外的维度信息。

核心亮点

  • 基于大规模开源语音数据集,识别准确率稳定
  • 轻量化部署,音频分类推理速度快
  • 适用于语音预处理、用户画像分析场景
  • Apache-2.0 协议,商业集成无压力

使用方法

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

model = AutoModel.from_pretrained("prithivMLmods/Common-Voice-Gender-Detection")
tokenizer = AutoTokenizer.from_pretrained("prithivMLmods/Common-Voice-Gender-Detection")

Hugging Face 下载

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

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

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download prithivMLmods/Common-Voice-Gender-Detection

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

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download prithivMLmods/Common-Voice-Gender-Detection config.json --local-dir ./dir

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

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('prithivMLmods/Common-Voice-Gender-Detection')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/prithivMLmods/Common-Voice-Gender-Detection

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

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/prithivMLmods/Common-Voice-Gender-Detection

模型文件托管在 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('prithivMLmods/Common-Voice-Gender-Detection')
tokenizer = AutoTokenizer.from_pretrained('prithivMLmods/Common-Voice-Gender-Detection')

模型下载

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

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

操作指引
pip install modelscope

命令行下载

下载完整模型库

下载完整模型库
modelscope download --model prithivMLmods/Common-Voice-Gender-Detection

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

下载单个文件到指定本地文件夹(以下载 README.md 到当前路径下 dir 目录为例)
modelscope download --model prithivMLmods/Common-Voice-Gender-Detection README.md --local_dir ./dir

更多更丰富的命令行下载选项,可参见具体文档

SDK 下载

SDK 下载
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('prithivMLmods/Common-Voice-Gender-Detection')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://www.modelscope.cn/prithivMLmods/Common-Voice-Gender-Detection.git

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

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/prithivMLmods/Common-Voice-Gender-Detection.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook 快速开发

下载并安装 ModelScope library

下载并安装 ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

模型加载和推理

模型加载和推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'prithivMLmods/Common-Voice-Gender-Detection')

完整文档

来源: HuggingFace

---
license: apache-2.0
language:

  • en

base_model:
  • facebook/wav2vec2-base-960h

pipeline_tag: audio-classification
library_name: transformers
tags:
  • voice-gender-detection

  • male

  • female

  • biology

  • SFT

---

!1

Common-Voice-Gender-Detection

> Common-Voice-Gender-Detection is a fine-tuned version of facebook/wav2vec2-base-960h for binary audio classification, specifically trained to detect speaker gender as female or male. This model leverages the Wav2Vec2ForSequenceClassification architecture for efficient and accurate voice-based gender classification.

> [!note]
Wav2Vec2: Self-Supervised Learning for Speech Recognition : https://arxiv.org/pdf/2006.11477

py
Classification Report:

precision recall f1-score support

female 0.9705 0.9916 0.9809 2622
male 0.9943 0.9799 0.9870 3923

accuracy 0.9846 6545
macro avg 0.9824 0.9857 0.9840 6545
weighted avg 0.9848 0.9846 0.9846 6545

!download.png

!download (1).png

---

Label Space: 2 Classes

code
Class 0: female  
Class 1: male

---

Install Dependencies

bash
pip install gradio transformers torch librosa hf_xet

---

Inference Code

python
import gradio as gr
from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
import torch
import librosa

Load model and processor

model_name = "prithivMLmods/Common-Voice-Geneder-Detection" model = Wav2Vec2ForSequenceClassification.from_pretrained(model_name) processor = Wav2Vec2FeatureExtractor.from_pretrained(model_name)

Label mapping

id2label = { "0": "female", "1": "male" }

def classify_audio(audio_path):
# Load and resample audio to 16kHz
speech, sample_rate = librosa.load(audio_path, sr=16000)

# Process audio
inputs = processor(
speech,
sampling_rate=sample_rate,
return_tensors="pt",
padding=True
)

with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()

prediction = {
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
}

return prediction

Gradio Interface

iface = gr.Interface( fn=classify_audio, inputs=gr.Audio(type="filepath", label="Upload Audio (WAV, MP3, etc.)"), outputs=gr.Label(num_top_classes=2, label="Gender Classification"), title="Common Voice Gender Detection", description="Upload an audio clip to classify the speaker's gender as female or male." )

if __name__ == "__main__":
iface.launch()

---

Demo Inference

> [!note]
male

<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/7woMf3_bgX_D99-1Uy3jH.mpga"></audio>

!Screenshot 2025-05-31 at 20-19-39 Common Voice Gender Detection.png

> [!note]
female

<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/0d2rDf_DT-gjRWBwiPbm_.mpga"></audio>

!Screenshot 2025-05-31 at 20-21-57 Common Voice Gender Detection.png

---

Intended Use

Common-Voice-Gender-Detection is designed for:

  • Speech Analytics – Assist in analyzing speaker demographics in call centers or customer service recordings.
  • Conversational AI Personalization – Adjust tone or dialogue based on gender detection for more personalized voice assistants.
  • Voice Dataset Curation – Automatically tag or filter voice datasets by speaker gender for better dataset management.
  • Research Applications – Enable linguistic and acoustic research involving gender-specific speech patterns.
  • Multimedia Content Tagging – Automate metadata generation for gender identification in podcasts, interviews, or video content.