README.md
| 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). |