mishig HF staff commited on
Commit
2fdcda4
1 Parent(s): 5a14d37

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - superb
5
+ tags:
6
+ - speech
7
+ - audio
8
+ - wav2vec2
9
+ - audio-classification
10
+ widget:
11
+ - label: VoxCeleb Speaker id10003
12
+ src: https://cdn-media.huggingface.co/speech_samples/VoxCeleb1_00003.wav
13
+ - label: VoxCeleb Speaker id10004
14
+ src: https://cdn-media.huggingface.co/speech_samples/VoxCeleb_00004.wav
15
+ license: apache-2.0
16
+ ---
17
+
18
+ # Wav2Vec2-Base for Speaker Identification
19
+
20
+ ## Model description
21
+
22
+ This is a ported version of
23
+ [S3PRL's Wav2Vec2 for the SUPERB Speaker Identification task](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream/voxceleb1).
24
+
25
+ The base model is [wav2vec2-base](https://huggingface.co/facebook/wav2vec2-base), which is pretrained on 16kHz
26
+ sampled speech audio. When using the model make sure that your speech input is also sampled at 16Khz.
27
+
28
+ For more information refer to [SUPERB: Speech processing Universal PERformance Benchmark](https://arxiv.org/abs/2105.01051)
29
+
30
+ ## Task and dataset description
31
+
32
+ Speaker Identification (SI) classifies each utterance for its speaker identity as a multi-class
33
+ classification, where speakers are in the same predefined set for both training and testing. The widely
34
+ used [VoxCeleb1](https://www.robots.ox.ac.uk/~vgg/data/voxceleb/vox1.html) dataset is adopted
35
+
36
+ For the original model's training and evaluation instructions refer to the
37
+ [S3PRL downstream task README](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream#sid-speaker-identification).
38
+
39
+
40
+ ## Usage examples
41
+
42
+ You can use the model via the Audio Classification pipeline:
43
+ ```python
44
+ from datasets import load_dataset
45
+ from transformers import pipeline
46
+
47
+ dataset = load_dataset("anton-l/superb_demo", "si", split="test")
48
+
49
+ classifier = pipeline("audio-classification", model="superb/wav2vec2-base-superb-sid")
50
+ labels = classifier(dataset[0]["file"], top_k=5)
51
+ ```
52
+
53
+ Or use the model directly:
54
+ ```python
55
+ import torch
56
+ import librosa
57
+ from datasets import load_dataset
58
+ from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
59
+
60
+ def map_to_array(example):
61
+ speech, _ = librosa.load(example["file"], sr=16000, mono=True)
62
+ example["speech"] = speech
63
+ return example
64
+
65
+ # load a demo dataset and read audio files
66
+ dataset = load_dataset("anton-l/superb_demo", "si", split="test")
67
+ dataset = dataset.map(map_to_array)
68
+
69
+ model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-sid")
70
+ feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-sid")
71
+
72
+ # compute attention masks and normalize the waveform if needed
73
+ inputs = feature_extractor(dataset[:2]["speech"], sampling_rate=16000, padding=True, return_tensors="pt")
74
+
75
+ logits = model(**inputs).logits
76
+ predicted_ids = torch.argmax(logits, dim=-1)
77
+ labels = [model.config.id2label[_id] for _id in predicted_ids.tolist()]
78
+ ```
79
+
80
+ ## Eval results
81
+
82
+ The evaluation metric is accuracy.
83
+
84
+ | | **s3prl** | **transformers** |
85
+ |--------|-----------|------------------|
86
+ |**test**| `0.7518` | `0.7518` |
87
+
88
+ ### BibTeX entry and citation info
89
+
90
+ ```bibtex
91
+ @article{yang2021superb,
92
+ title={SUPERB: Speech processing Universal PERformance Benchmark},
93
+ author={Yang, Shu-wen and Chi, Po-Han and Chuang, Yung-Sung and Lai, Cheng-I Jeff and Lakhotia, Kushal and Lin, Yist Y and Liu, Andy T and Shi, Jiatong and Chang, Xuankai and Lin, Guan-Ting and others},
94
+ journal={arXiv preprint arXiv:2105.01051},
95
+ year={2021}
96
+ }
97
+ ```