speech-test commited on
Commit
8f70151
1 Parent(s): 4630d04

Update info

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