mrhacker7599 commited on
Commit
c331cf0
·
verified ·
1 Parent(s): 5bb7ccb

Initial Commit

Browse files
Files changed (4) hide show
  1. README.md +96 -1
  2. config.json +101 -0
  3. preprocessor_config.json +9 -0
  4. pytorch_model.bin +3 -0
README.md CHANGED
@@ -1,3 +1,98 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
+ datasets:
4
+ - superb
5
+ tags:
6
+ - speech
7
+ - audio
8
+ - wav2vec2
9
+ - audio-classification
10
+ license: apache-2.0
11
+ widget:
12
+ - example_title: IEMOCAP clip "happy"
13
+ src: https://cdn-media.huggingface.co/speech_samples/IEMOCAP_Ses01F_impro03_F013.wav
14
+ - example_title: IEMOCAP clip "neutral"
15
+ src: https://cdn-media.huggingface.co/speech_samples/IEMOCAP_Ses01F_impro04_F000.wav
16
  ---
17
+
18
+ # Wav2Vec2-Base for Emotion Recognition
19
+
20
+ ## Model description
21
+
22
+ This is a ported version of
23
+ [S3PRL's Wav2Vec2 for the SUPERB Emotion Recognition task](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream/emotion).
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
+ Emotion Recognition (ER) predicts an emotion class for each utterance. The most widely used ER dataset
33
+ [IEMOCAP](https://sail.usc.edu/iemocap/) is adopted, and we follow the conventional evaluation protocol:
34
+ we drop the unbalanced emotion classes to leave the final four classes with a similar amount of data points and
35
+ cross-validate on five folds of the standard splits.
36
+
37
+ For the original model's training and evaluation instructions refer to the
38
+ [S3PRL downstream task README](https://github.com/s3prl/s3prl/tree/master/s3prl/downstream#er-emotion-recognition).
39
+
40
+
41
+ ## Usage examples
42
+
43
+ You can use the model via the Audio Classification pipeline:
44
+ ```python
45
+ from datasets import load_dataset
46
+ from transformers import pipeline
47
+
48
+ dataset = load_dataset("anton-l/superb_demo", "er", split="session1")
49
+
50
+ classifier = pipeline("audio-classification", model="superb/wav2vec2-base-superb-er")
51
+ labels = classifier(dataset[0]["file"], top_k=5)
52
+ ```
53
+
54
+ Or use the model directly:
55
+ ```python
56
+ import torch
57
+ import librosa
58
+ from datasets import load_dataset
59
+ from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
60
+
61
+ def map_to_array(example):
62
+ speech, _ = librosa.load(example["file"], sr=16000, mono=True)
63
+ example["speech"] = speech
64
+ return example
65
+
66
+ # load a demo dataset and read audio files
67
+ dataset = load_dataset("anton-l/superb_demo", "er", split="session1")
68
+ dataset = dataset.map(map_to_array)
69
+
70
+ model = Wav2Vec2ForSequenceClassification.from_pretrained("superb/wav2vec2-base-superb-er")
71
+ feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/wav2vec2-base-superb-er")
72
+
73
+ # compute attention masks and normalize the waveform if needed
74
+ inputs = feature_extractor(dataset[:4]["speech"], sampling_rate=16000, padding=True, return_tensors="pt")
75
+
76
+ logits = model(**inputs).logits
77
+ predicted_ids = torch.argmax(logits, dim=-1)
78
+ labels = [model.config.id2label[_id] for _id in predicted_ids.tolist()]
79
+ ```
80
+
81
+ ## Eval results
82
+
83
+ The evaluation metric is accuracy.
84
+
85
+ | | **s3prl** | **transformers** |
86
+ |--------|-----------|------------------|
87
+ |**session1**| `0.6343` | `0.6258` |
88
+
89
+ ### BibTeX entry and citation info
90
+
91
+ ```bibtex
92
+ @article{yang2021superb,
93
+ title={SUPERB: Speech processing Universal PERformance Benchmark},
94
+ 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},
95
+ journal={arXiv preprint arXiv:2105.01051},
96
+ year={2021}
97
+ }
98
+ ```
config.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/wav2vec2-base",
3
+ "activation_dropout": 0.0,
4
+ "apply_spec_augment": true,
5
+ "architectures": [
6
+ "Wav2Vec2ForSequenceClassification"
7
+ ],
8
+ "attention_dropout": 0.1,
9
+ "bos_token_id": 1,
10
+ "classifier_proj_size": 256,
11
+ "codevector_dim": 256,
12
+ "contrastive_logits_temperature": 0.1,
13
+ "conv_bias": false,
14
+ "conv_dim": [
15
+ 512,
16
+ 512,
17
+ 512,
18
+ 512,
19
+ 512,
20
+ 512,
21
+ 512
22
+ ],
23
+ "conv_kernel": [
24
+ 10,
25
+ 3,
26
+ 3,
27
+ 3,
28
+ 3,
29
+ 2,
30
+ 2
31
+ ],
32
+ "conv_stride": [
33
+ 5,
34
+ 2,
35
+ 2,
36
+ 2,
37
+ 2,
38
+ 2,
39
+ 2
40
+ ],
41
+ "ctc_loss_reduction": "sum",
42
+ "ctc_zero_infinity": false,
43
+ "diversity_loss_weight": 0.1,
44
+ "do_stable_layer_norm": false,
45
+ "eos_token_id": 2,
46
+ "feat_extract_activation": "gelu",
47
+ "feat_extract_norm": "group",
48
+ "feat_proj_dropout": 0.1,
49
+ "feat_quantizer_dropout": 0.0,
50
+ "final_dropout": 0.0,
51
+ "freeze_feat_extract_train": true,
52
+ "gradient_checkpointing": true,
53
+ "hidden_act": "gelu",
54
+ "hidden_dropout": 0.1,
55
+ "hidden_size": 768,
56
+ "id2label": {
57
+ "0": "neu",
58
+ "1": "hap",
59
+ "2": "ang",
60
+ "3": "sad"
61
+ },
62
+ "initializer_range": 0.02,
63
+ "intermediate_size": 3072,
64
+ "label2id": {
65
+ "ang": 2,
66
+ "hap": 1,
67
+ "neu": 0,
68
+ "sad": 3
69
+ },
70
+ "layer_norm_eps": 1e-05,
71
+ "layerdrop": 0.05,
72
+ "mask_channel_length": 10,
73
+ "mask_channel_min_space": 1,
74
+ "mask_channel_other": 0.0,
75
+ "mask_channel_prob": 0.0,
76
+ "mask_channel_selection": "static",
77
+ "mask_feature_length": 10,
78
+ "mask_feature_prob": 0.0,
79
+ "mask_time_length": 10,
80
+ "mask_time_min_space": 1,
81
+ "mask_time_other": 0.0,
82
+ "mask_time_prob": 0.05,
83
+ "mask_time_selection": "static",
84
+ "model_type": "wav2vec2",
85
+ "no_mask_channel_overlap": false,
86
+ "no_mask_time_overlap": false,
87
+ "num_attention_heads": 12,
88
+ "num_codevector_groups": 2,
89
+ "num_codevectors_per_group": 320,
90
+ "num_conv_pos_embedding_groups": 16,
91
+ "num_conv_pos_embeddings": 128,
92
+ "num_feat_extract_layers": 7,
93
+ "num_hidden_layers": 12,
94
+ "num_negatives": 100,
95
+ "pad_token_id": 0,
96
+ "proj_codevector_dim": 256,
97
+ "torch_dtype": "float32",
98
+ "transformers_version": "4.10.0.dev0",
99
+ "use_weighted_layer_sum": true,
100
+ "vocab_size": 32
101
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": false,
3
+ "feature_extractor_type": "Wav2Vec2FeatureExtractor",
4
+ "feature_size": 1,
5
+ "padding_side": "right",
6
+ "padding_value": 0.0,
7
+ "return_attention_mask": true,
8
+ "sampling_rate": 16000
9
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e338e0b3ff74da7e0c3e460d9f178212ab32fd0996d98a58f535e777325832b9
3
+ size 134