Commit ·
509c9e7
0
Parent(s):
Duplicate from JaesungHuh/voice-gender-classifier
Browse filesCo-authored-by: Huh <JaesungHuh@users.noreply.huggingface.co>
- .gitattributes +35 -0
- .gitignore +1 -0
- README.md +67 -0
- config.json +3 -0
- example1.wav +0 -0
- example2.wav +0 -0
- model.safetensors +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.DS_Store
|
README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- pytorch_model_hub_mixin
|
| 4 |
+
- model_hub_mixin
|
| 5 |
+
- gender-classification
|
| 6 |
+
- VoxCeleb
|
| 7 |
+
license: mit
|
| 8 |
+
datasets:
|
| 9 |
+
- ProgramComputer/voxceleb
|
| 10 |
+
pipeline_tag: audio-classification
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Voice gender classifier
|
| 14 |
+
- This repo contains the inference code to use pretrained human voice gender classifier.
|
| 15 |
+
- You could also try 🤗[Huggingface online demo](https://huggingface.co/spaces/JaesungHuh/voice-gender-classifier).
|
| 16 |
+
|
| 17 |
+
## Installation
|
| 18 |
+
First, clone the original [github repository](https://github.com/JaesungHuh/voice-gender-classifier)
|
| 19 |
+
```
|
| 20 |
+
git clone https://github.com/JaesungHuh/voice-gender-classifier.git
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
and install the packages via pip.
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
cd voice-gender-classifier
|
| 27 |
+
pip install -r requirements.txt
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
## Usage
|
| 31 |
+
```
|
| 32 |
+
import torch
|
| 33 |
+
|
| 34 |
+
from model import ECAPA_gender
|
| 35 |
+
|
| 36 |
+
# You could directly download the model from the huggingface model hub
|
| 37 |
+
model = ECAPA_gender.from_pretrained("JaesungHuh/voice-gender-classifier")
|
| 38 |
+
model.eval()
|
| 39 |
+
|
| 40 |
+
# If you are using gpu ....
|
| 41 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 42 |
+
model.to(device)
|
| 43 |
+
|
| 44 |
+
# Load the audio file and use predict function to directly get the output
|
| 45 |
+
example_file = "data/00001.wav"
|
| 46 |
+
with torch.no_grad():
|
| 47 |
+
output = model.predict(example_file, device=device)
|
| 48 |
+
print("Gender : ", output)
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## Pretrained weights
|
| 52 |
+
For those who need pretrained weights, please download it in [here](https://drive.google.com/file/d/1ojtaa6VyUhEM49F7uEyvsLSVN3T8bbPI/view?usp=sharing)
|
| 53 |
+
|
| 54 |
+
## Training details
|
| 55 |
+
State-of-the-art speaker verification model already produces good representation of the speaker's gender.
|
| 56 |
+
|
| 57 |
+
I used the pretrained ECAPA-TDNN from [TaoRuijie's](https://github.com/TaoRuijie/ECAPA-TDNN) repository, added one linear layer to make two-class classifier, and finetuned the model with the VoxCeleb2 dev set.
|
| 58 |
+
|
| 59 |
+
The model achieved **98.7%** accuracy on the VoxCeleb1 identification test split.
|
| 60 |
+
|
| 61 |
+
## Caveat
|
| 62 |
+
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.
|
| 63 |
+
|
| 64 |
+
## Reference
|
| 65 |
+
- [Original github repository](https://github.com/JaesungHuh/voice-gender-classifier)
|
| 66 |
+
- I modified the model architecture from [TaoRuijie's](https://github.com/TaoRuijie/ECAPA-TDNN) repository.
|
| 67 |
+
- For more details about ECAPA-TDNN, check the [paper](https://arxiv.org/abs/2005.07143).
|
config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"C": 1024
|
| 3 |
+
}
|
example1.wav
ADDED
|
Binary file (268 kB). View file
|
|
|
example2.wav
ADDED
|
Binary file (238 kB). View file
|
|
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d8e0be1fdf159d60d5087416e6f6277c5e30ce9e33a61c767a9a409e6c503c5
|
| 3 |
+
size 61907512
|