KaiChen1998 commited on
Commit
02e65c1
·
verified ·
1 Parent(s): b1ac221

Upload tokenizer

Browse files
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
config.json ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "hf/",
3
+ "architectures": [
4
+ "EMOVASpeechTokenizer"
5
+ ],
6
+ "auto_map": {
7
+ "AutoConfig": [
8
+ "configuration_emova_speech_tokenizer.EMOVASpeechTokenizerConfig",
9
+ null
10
+ ],
11
+ "AutoModel": [
12
+ "modeling_emova_speech_tokenizer.EMOVASpeechTokenizer",
13
+ null
14
+ ]
15
+ },
16
+ "model_type": "EMOVASpeechTokenizer",
17
+ "s2u_unit_type": "40ms_multilingual_8888",
18
+ "torch_dtype": "float32",
19
+ "transformers_version": "4.44.2",
20
+ "u2s_dim_styles": 256,
21
+ "u2s_num_styles": 126,
22
+ "u2s_style2idx": {
23
+ "gender-female_emotion-angry_speed-fast_pitch-high": 0,
24
+ "gender-female_emotion-angry_speed-fast_pitch-low": 1,
25
+ "gender-female_emotion-angry_speed-fast_pitch-normal": 2,
26
+ "gender-female_emotion-angry_speed-normal_pitch-high": 3,
27
+ "gender-female_emotion-angry_speed-normal_pitch-low": 4,
28
+ "gender-female_emotion-angry_speed-normal_pitch-normal": 5,
29
+ "gender-female_emotion-angry_speed-slow_pitch-high": 6,
30
+ "gender-female_emotion-angry_speed-slow_pitch-low": 7,
31
+ "gender-female_emotion-angry_speed-slow_pitch-normal": 8,
32
+ "gender-female_emotion-disgusted_speed-fast_pitch-high": 9,
33
+ "gender-female_emotion-disgusted_speed-fast_pitch-low": 10,
34
+ "gender-female_emotion-disgusted_speed-fast_pitch-normal": 11,
35
+ "gender-female_emotion-disgusted_speed-normal_pitch-high": 12,
36
+ "gender-female_emotion-disgusted_speed-normal_pitch-low": 13,
37
+ "gender-female_emotion-disgusted_speed-normal_pitch-normal": 14,
38
+ "gender-female_emotion-disgusted_speed-slow_pitch-high": 15,
39
+ "gender-female_emotion-disgusted_speed-slow_pitch-low": 16,
40
+ "gender-female_emotion-disgusted_speed-slow_pitch-normal": 17,
41
+ "gender-female_emotion-fearful_speed-fast_pitch-high": 18,
42
+ "gender-female_emotion-fearful_speed-fast_pitch-low": 19,
43
+ "gender-female_emotion-fearful_speed-fast_pitch-normal": 20,
44
+ "gender-female_emotion-fearful_speed-normal_pitch-high": 21,
45
+ "gender-female_emotion-fearful_speed-normal_pitch-low": 22,
46
+ "gender-female_emotion-fearful_speed-normal_pitch-normal": 23,
47
+ "gender-female_emotion-fearful_speed-slow_pitch-high": 24,
48
+ "gender-female_emotion-fearful_speed-slow_pitch-low": 25,
49
+ "gender-female_emotion-fearful_speed-slow_pitch-normal": 26,
50
+ "gender-female_emotion-happy_speed-fast_pitch-high": 27,
51
+ "gender-female_emotion-happy_speed-fast_pitch-low": 28,
52
+ "gender-female_emotion-happy_speed-fast_pitch-normal": 29,
53
+ "gender-female_emotion-happy_speed-normal_pitch-high": 30,
54
+ "gender-female_emotion-happy_speed-normal_pitch-low": 31,
55
+ "gender-female_emotion-happy_speed-normal_pitch-normal": 32,
56
+ "gender-female_emotion-happy_speed-slow_pitch-high": 33,
57
+ "gender-female_emotion-happy_speed-slow_pitch-low": 34,
58
+ "gender-female_emotion-happy_speed-slow_pitch-normal": 35,
59
+ "gender-female_emotion-neutral_speed-fast_pitch-high": 36,
60
+ "gender-female_emotion-neutral_speed-fast_pitch-low": 37,
61
+ "gender-female_emotion-neutral_speed-fast_pitch-normal": 38,
62
+ "gender-female_emotion-neutral_speed-normal_pitch-high": 39,
63
+ "gender-female_emotion-neutral_speed-normal_pitch-low": 40,
64
+ "gender-female_emotion-neutral_speed-normal_pitch-normal": 41,
65
+ "gender-female_emotion-neutral_speed-slow_pitch-high": 42,
66
+ "gender-female_emotion-neutral_speed-slow_pitch-low": 43,
67
+ "gender-female_emotion-neutral_speed-slow_pitch-normal": 44,
68
+ "gender-female_emotion-sad_speed-fast_pitch-high": 45,
69
+ "gender-female_emotion-sad_speed-fast_pitch-low": 46,
70
+ "gender-female_emotion-sad_speed-fast_pitch-normal": 47,
71
+ "gender-female_emotion-sad_speed-normal_pitch-high": 48,
72
+ "gender-female_emotion-sad_speed-normal_pitch-low": 49,
73
+ "gender-female_emotion-sad_speed-normal_pitch-normal": 50,
74
+ "gender-female_emotion-sad_speed-slow_pitch-high": 51,
75
+ "gender-female_emotion-sad_speed-slow_pitch-low": 52,
76
+ "gender-female_emotion-sad_speed-slow_pitch-normal": 53,
77
+ "gender-female_emotion-surprised_speed-fast_pitch-high": 54,
78
+ "gender-female_emotion-surprised_speed-fast_pitch-low": 55,
79
+ "gender-female_emotion-surprised_speed-fast_pitch-normal": 56,
80
+ "gender-female_emotion-surprised_speed-normal_pitch-high": 57,
81
+ "gender-female_emotion-surprised_speed-normal_pitch-low": 58,
82
+ "gender-female_emotion-surprised_speed-normal_pitch-normal": 59,
83
+ "gender-female_emotion-surprised_speed-slow_pitch-high": 60,
84
+ "gender-female_emotion-surprised_speed-slow_pitch-low": 61,
85
+ "gender-female_emotion-surprised_speed-slow_pitch-normal": 62,
86
+ "gender-male_emotion-angry_speed-fast_pitch-high": 63,
87
+ "gender-male_emotion-angry_speed-fast_pitch-low": 64,
88
+ "gender-male_emotion-angry_speed-fast_pitch-normal": 65,
89
+ "gender-male_emotion-angry_speed-normal_pitch-high": 66,
90
+ "gender-male_emotion-angry_speed-normal_pitch-low": 67,
91
+ "gender-male_emotion-angry_speed-normal_pitch-normal": 68,
92
+ "gender-male_emotion-angry_speed-slow_pitch-high": 69,
93
+ "gender-male_emotion-angry_speed-slow_pitch-low": 70,
94
+ "gender-male_emotion-angry_speed-slow_pitch-normal": 71,
95
+ "gender-male_emotion-disgusted_speed-fast_pitch-high": 72,
96
+ "gender-male_emotion-disgusted_speed-fast_pitch-low": 73,
97
+ "gender-male_emotion-disgusted_speed-fast_pitch-normal": 74,
98
+ "gender-male_emotion-disgusted_speed-normal_pitch-high": 75,
99
+ "gender-male_emotion-disgusted_speed-normal_pitch-low": 76,
100
+ "gender-male_emotion-disgusted_speed-normal_pitch-normal": 77,
101
+ "gender-male_emotion-disgusted_speed-slow_pitch-high": 78,
102
+ "gender-male_emotion-disgusted_speed-slow_pitch-low": 79,
103
+ "gender-male_emotion-disgusted_speed-slow_pitch-normal": 80,
104
+ "gender-male_emotion-fearful_speed-fast_pitch-high": 81,
105
+ "gender-male_emotion-fearful_speed-fast_pitch-low": 82,
106
+ "gender-male_emotion-fearful_speed-fast_pitch-normal": 83,
107
+ "gender-male_emotion-fearful_speed-normal_pitch-high": 84,
108
+ "gender-male_emotion-fearful_speed-normal_pitch-low": 85,
109
+ "gender-male_emotion-fearful_speed-normal_pitch-normal": 86,
110
+ "gender-male_emotion-fearful_speed-slow_pitch-high": 87,
111
+ "gender-male_emotion-fearful_speed-slow_pitch-low": 88,
112
+ "gender-male_emotion-fearful_speed-slow_pitch-normal": 89,
113
+ "gender-male_emotion-happy_speed-fast_pitch-high": 90,
114
+ "gender-male_emotion-happy_speed-fast_pitch-low": 91,
115
+ "gender-male_emotion-happy_speed-fast_pitch-normal": 92,
116
+ "gender-male_emotion-happy_speed-normal_pitch-high": 93,
117
+ "gender-male_emotion-happy_speed-normal_pitch-low": 94,
118
+ "gender-male_emotion-happy_speed-normal_pitch-normal": 95,
119
+ "gender-male_emotion-happy_speed-slow_pitch-high": 96,
120
+ "gender-male_emotion-happy_speed-slow_pitch-low": 97,
121
+ "gender-male_emotion-happy_speed-slow_pitch-normal": 98,
122
+ "gender-male_emotion-neutral_speed-fast_pitch-high": 99,
123
+ "gender-male_emotion-neutral_speed-fast_pitch-low": 100,
124
+ "gender-male_emotion-neutral_speed-fast_pitch-normal": 101,
125
+ "gender-male_emotion-neutral_speed-normal_pitch-high": 102,
126
+ "gender-male_emotion-neutral_speed-normal_pitch-low": 103,
127
+ "gender-male_emotion-neutral_speed-normal_pitch-normal": 104,
128
+ "gender-male_emotion-neutral_speed-slow_pitch-high": 105,
129
+ "gender-male_emotion-neutral_speed-slow_pitch-low": 106,
130
+ "gender-male_emotion-neutral_speed-slow_pitch-normal": 107,
131
+ "gender-male_emotion-sad_speed-fast_pitch-high": 108,
132
+ "gender-male_emotion-sad_speed-fast_pitch-low": 109,
133
+ "gender-male_emotion-sad_speed-fast_pitch-normal": 110,
134
+ "gender-male_emotion-sad_speed-normal_pitch-high": 111,
135
+ "gender-male_emotion-sad_speed-normal_pitch-low": 112,
136
+ "gender-male_emotion-sad_speed-normal_pitch-normal": 113,
137
+ "gender-male_emotion-sad_speed-slow_pitch-high": 114,
138
+ "gender-male_emotion-sad_speed-slow_pitch-low": 115,
139
+ "gender-male_emotion-sad_speed-slow_pitch-normal": 116,
140
+ "gender-male_emotion-surprised_speed-fast_pitch-high": 117,
141
+ "gender-male_emotion-surprised_speed-fast_pitch-low": 118,
142
+ "gender-male_emotion-surprised_speed-fast_pitch-normal": 119,
143
+ "gender-male_emotion-surprised_speed-normal_pitch-high": 120,
144
+ "gender-male_emotion-surprised_speed-normal_pitch-low": 121,
145
+ "gender-male_emotion-surprised_speed-normal_pitch-normal": 122,
146
+ "gender-male_emotion-surprised_speed-slow_pitch-high": 123,
147
+ "gender-male_emotion-surprised_speed-slow_pitch-low": 124,
148
+ "gender-male_emotion-surprised_speed-slow_pitch-normal": 125
149
+ },
150
+ "u2s_unit_type": "40ms_multilingual_8888_xujing_cosyvoice_FT"
151
+ }
configuration_emova_speech_tokenizer.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The EMOVA team and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """ EMOVASpeechTokenizer model configuration """
16
+
17
+ import copy
18
+ from typing import List
19
+
20
+ from transformers.configuration_utils import PretrainedConfig
21
+ from transformers.utils import logging
22
+
23
+ logger = logging.get_logger(__name__)
24
+
25
+ U2S_STYLES = [
26
+ 'gender-female_emotion-angry_speed-fast_pitch-high', 'gender-female_emotion-angry_speed-fast_pitch-low', 'gender-female_emotion-angry_speed-fast_pitch-normal',
27
+ 'gender-female_emotion-angry_speed-normal_pitch-high', 'gender-female_emotion-angry_speed-normal_pitch-low', 'gender-female_emotion-angry_speed-normal_pitch-normal',
28
+ 'gender-female_emotion-angry_speed-slow_pitch-high', 'gender-female_emotion-angry_speed-slow_pitch-low', 'gender-female_emotion-angry_speed-slow_pitch-normal',
29
+ 'gender-female_emotion-disgusted_speed-fast_pitch-high', 'gender-female_emotion-disgusted_speed-fast_pitch-low', 'gender-female_emotion-disgusted_speed-fast_pitch-normal',
30
+ 'gender-female_emotion-disgusted_speed-normal_pitch-high', 'gender-female_emotion-disgusted_speed-normal_pitch-low', 'gender-female_emotion-disgusted_speed-normal_pitch-normal',
31
+ 'gender-female_emotion-disgusted_speed-slow_pitch-high', 'gender-female_emotion-disgusted_speed-slow_pitch-low', 'gender-female_emotion-disgusted_speed-slow_pitch-normal',
32
+ 'gender-female_emotion-fearful_speed-fast_pitch-high', 'gender-female_emotion-fearful_speed-fast_pitch-low', 'gender-female_emotion-fearful_speed-fast_pitch-normal',
33
+ 'gender-female_emotion-fearful_speed-normal_pitch-high', 'gender-female_emotion-fearful_speed-normal_pitch-low', 'gender-female_emotion-fearful_speed-normal_pitch-normal',
34
+ 'gender-female_emotion-fearful_speed-slow_pitch-high', 'gender-female_emotion-fearful_speed-slow_pitch-low', 'gender-female_emotion-fearful_speed-slow_pitch-normal',
35
+ 'gender-female_emotion-happy_speed-fast_pitch-high', 'gender-female_emotion-happy_speed-fast_pitch-low', 'gender-female_emotion-happy_speed-fast_pitch-normal',
36
+ 'gender-female_emotion-happy_speed-normal_pitch-high', 'gender-female_emotion-happy_speed-normal_pitch-low', 'gender-female_emotion-happy_speed-normal_pitch-normal',
37
+ 'gender-female_emotion-happy_speed-slow_pitch-high', 'gender-female_emotion-happy_speed-slow_pitch-low', 'gender-female_emotion-happy_speed-slow_pitch-normal',
38
+ 'gender-female_emotion-neutral_speed-fast_pitch-high', 'gender-female_emotion-neutral_speed-fast_pitch-low', 'gender-female_emotion-neutral_speed-fast_pitch-normal',
39
+ 'gender-female_emotion-neutral_speed-normal_pitch-high', 'gender-female_emotion-neutral_speed-normal_pitch-low', 'gender-female_emotion-neutral_speed-normal_pitch-normal',
40
+ 'gender-female_emotion-neutral_speed-slow_pitch-high', 'gender-female_emotion-neutral_speed-slow_pitch-low', 'gender-female_emotion-neutral_speed-slow_pitch-normal',
41
+ 'gender-female_emotion-sad_speed-fast_pitch-high', 'gender-female_emotion-sad_speed-fast_pitch-low', 'gender-female_emotion-sad_speed-fast_pitch-normal',
42
+ 'gender-female_emotion-sad_speed-normal_pitch-high', 'gender-female_emotion-sad_speed-normal_pitch-low', 'gender-female_emotion-sad_speed-normal_pitch-normal',
43
+ 'gender-female_emotion-sad_speed-slow_pitch-high', 'gender-female_emotion-sad_speed-slow_pitch-low', 'gender-female_emotion-sad_speed-slow_pitch-normal',
44
+ 'gender-female_emotion-surprised_speed-fast_pitch-high', 'gender-female_emotion-surprised_speed-fast_pitch-low', 'gender-female_emotion-surprised_speed-fast_pitch-normal',
45
+ 'gender-female_emotion-surprised_speed-normal_pitch-high', 'gender-female_emotion-surprised_speed-normal_pitch-low', 'gender-female_emotion-surprised_speed-normal_pitch-normal',
46
+ 'gender-female_emotion-surprised_speed-slow_pitch-high', 'gender-female_emotion-surprised_speed-slow_pitch-low', 'gender-female_emotion-surprised_speed-slow_pitch-normal',
47
+ 'gender-male_emotion-angry_speed-fast_pitch-high', 'gender-male_emotion-angry_speed-fast_pitch-low', 'gender-male_emotion-angry_speed-fast_pitch-normal',
48
+ 'gender-male_emotion-angry_speed-normal_pitch-high', 'gender-male_emotion-angry_speed-normal_pitch-low', 'gender-male_emotion-angry_speed-normal_pitch-normal',
49
+ 'gender-male_emotion-angry_speed-slow_pitch-high', 'gender-male_emotion-angry_speed-slow_pitch-low', 'gender-male_emotion-angry_speed-slow_pitch-normal',
50
+ 'gender-male_emotion-disgusted_speed-fast_pitch-high', 'gender-male_emotion-disgusted_speed-fast_pitch-low', 'gender-male_emotion-disgusted_speed-fast_pitch-normal',
51
+ 'gender-male_emotion-disgusted_speed-normal_pitch-high', 'gender-male_emotion-disgusted_speed-normal_pitch-low', 'gender-male_emotion-disgusted_speed-normal_pitch-normal',
52
+ 'gender-male_emotion-disgusted_speed-slow_pitch-high', 'gender-male_emotion-disgusted_speed-slow_pitch-low', 'gender-male_emotion-disgusted_speed-slow_pitch-normal',
53
+ 'gender-male_emotion-fearful_speed-fast_pitch-high', 'gender-male_emotion-fearful_speed-fast_pitch-low', 'gender-male_emotion-fearful_speed-fast_pitch-normal',
54
+ 'gender-male_emotion-fearful_speed-normal_pitch-high', 'gender-male_emotion-fearful_speed-normal_pitch-low', 'gender-male_emotion-fearful_speed-normal_pitch-normal',
55
+ 'gender-male_emotion-fearful_speed-slow_pitch-high', 'gender-male_emotion-fearful_speed-slow_pitch-low', 'gender-male_emotion-fearful_speed-slow_pitch-normal',
56
+ 'gender-male_emotion-happy_speed-fast_pitch-high', 'gender-male_emotion-happy_speed-fast_pitch-low', 'gender-male_emotion-happy_speed-fast_pitch-normal',
57
+ 'gender-male_emotion-happy_speed-normal_pitch-high', 'gender-male_emotion-happy_speed-normal_pitch-low', 'gender-male_emotion-happy_speed-normal_pitch-normal',
58
+ 'gender-male_emotion-happy_speed-slow_pitch-high', 'gender-male_emotion-happy_speed-slow_pitch-low', 'gender-male_emotion-happy_speed-slow_pitch-normal',
59
+ 'gender-male_emotion-neutral_speed-fast_pitch-high', 'gender-male_emotion-neutral_speed-fast_pitch-low', 'gender-male_emotion-neutral_speed-fast_pitch-normal',
60
+ 'gender-male_emotion-neutral_speed-normal_pitch-high', 'gender-male_emotion-neutral_speed-normal_pitch-low', 'gender-male_emotion-neutral_speed-normal_pitch-normal',
61
+ 'gender-male_emotion-neutral_speed-slow_pitch-high', 'gender-male_emotion-neutral_speed-slow_pitch-low', 'gender-male_emotion-neutral_speed-slow_pitch-normal',
62
+ 'gender-male_emotion-sad_speed-fast_pitch-high', 'gender-male_emotion-sad_speed-fast_pitch-low', 'gender-male_emotion-sad_speed-fast_pitch-normal',
63
+ 'gender-male_emotion-sad_speed-normal_pitch-high', 'gender-male_emotion-sad_speed-normal_pitch-low', 'gender-male_emotion-sad_speed-normal_pitch-normal',
64
+ 'gender-male_emotion-sad_speed-slow_pitch-high', 'gender-male_emotion-sad_speed-slow_pitch-low', 'gender-male_emotion-sad_speed-slow_pitch-normal',
65
+ 'gender-male_emotion-surprised_speed-fast_pitch-high', 'gender-male_emotion-surprised_speed-fast_pitch-low', 'gender-male_emotion-surprised_speed-fast_pitch-normal',
66
+ 'gender-male_emotion-surprised_speed-normal_pitch-high', 'gender-male_emotion-surprised_speed-normal_pitch-low', 'gender-male_emotion-surprised_speed-normal_pitch-normal',
67
+ 'gender-male_emotion-surprised_speed-slow_pitch-high', 'gender-male_emotion-surprised_speed-slow_pitch-low', 'gender-male_emotion-surprised_speed-slow_pitch-normal'
68
+ ]
69
+
70
+ class EMOVASpeechTokenizerConfig(PretrainedConfig):
71
+ r"""
72
+ This is the configuration class to store the configuration of a [`EMOVASpeechTokenizer`]. It is used to instantiate
73
+ a EMOVASpeechTokenizer model especially designed for training the EMOVA (https://arxiv.org/abs/2409.18042)
74
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
75
+ defaults will yield a configuration to the speech tokenizer model presented in EMOVA paper.
76
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
77
+ documentation from [`PretrainedConfig`] for more information.
78
+ Args:
79
+ s2u_unit_type (`str`, defaults to `40ms_multilingual_8888`):
80
+ Unit type to specify model configurations for the speech-to-unit (S2U) encoder. Detailed configs will be found accordingly.
81
+ u2s_unit_type (`str`, defaults to `40ms_multilingual_8888_xujing_cosyvoice_FT`):
82
+ Unit type to specify model configurations for the unit-to-speech (U2S) decoder. Detailed configs will be found accordingly.
83
+ u2s_num_styles, u2s_dim_styles (`int`, defaults to 126 and 256):
84
+ Size of the style embedding matrix.
85
+ ```python
86
+ >>> from transformers import EMOVASpeechTokenizerConfig, EMOVASpeechTokenizer
87
+ >>> # Initializing a EMOVA speech tokenizer configuration
88
+ >>> configuration = EMOVASpeechTokenizerConfig()
89
+ >>> # Initializing a model from the EMOVA speech tokenizer configuration
90
+ >>> model = EMOVASpeechTokenizer(configuration)
91
+ >>> # Accessing the model configuration
92
+ >>> configuration = model.config
93
+ ```"""
94
+
95
+ model_type = "EMOVASpeechTokenizer"
96
+
97
+ def __init__(
98
+ self,
99
+ s2u_unit_type="40ms_multilingual_8888",
100
+ u2s_unit_type="40ms_multilingual_8888_xujing_cosyvoice_FT",
101
+ u2s_num_styles=126,
102
+ u2s_dim_styles=256,
103
+ **kwargs,
104
+ ):
105
+ super().__init__(**kwargs)
106
+
107
+ self.s2u_unit_type = s2u_unit_type
108
+ self.u2s_unit_type = u2s_unit_type
109
+ self.u2s_num_styles = u2s_num_styles
110
+ self.u2s_dim_styles = u2s_dim_styles
111
+ self.u2s_style2idx = {each:i for i, each in enumerate(U2S_STYLES)}
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f01ab4b6cbe65d477f5d57e704f1324104f5437b1517c8938a194be2d98a7a6
3
+ size 546644908
modeling_emova_speech_tokenizer.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The EMOVA team and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """ EMOVASpeechTokenizer model """
16
+
17
+ import math
18
+ from typing import Optional, Tuple, Union
19
+
20
+ import torch
21
+ import torch.nn as nn
22
+ from transformers.modeling_utils import PreTrainedModel
23
+
24
+ try:
25
+ from emova_speech_tokenizer.speech_utils import get_S2U_ckpt_config_path, load_config, VQCTCFinetuneModel, s2u_extract_unit_demo
26
+ from emova_speech_tokenizer.speech_utils import get_U2S_config_checkpoint_file, load_U2S_config, SynthesizerTrn, synthesis
27
+ except:
28
+ raise ImportError('Dependencies of emova speech tokenizer are not installed properly. Check https://huggingface.co/Emova-ollm/emova_speech_tokenizer#install for detailed instructions.')
29
+
30
+ from .configuration_emova_speech_tokenizer import EMOVASpeechTokenizerConfig
31
+
32
+ class EMOVASpeechTokenizer(PreTrainedModel):
33
+ config_class = EMOVASpeechTokenizerConfig
34
+ base_model_prefix = "emova_speech_tokenizer"
35
+
36
+ def __init__(self, config: EMOVASpeechTokenizerConfig):
37
+ super().__init__(config)
38
+ self.config = config
39
+
40
+ # s2u encoder configs
41
+ _, S2U_config_path = get_S2U_ckpt_config_path(config.s2u_unit_type)
42
+ s2u_cfg = load_config(config=S2U_config_path)
43
+ s2u_cfg.model.pretrain_chkpt_path = None
44
+
45
+ # u2s decoder configs
46
+ U2S_config_file, _ = get_U2S_config_checkpoint_file(config.u2s_unit_type)
47
+ u2s_cfg = load_U2S_config(U2S_config_file)
48
+
49
+ # construct models
50
+ self.s2u_config = s2u_cfg.model
51
+ self.u2s_config = u2s_cfg
52
+ self.encoder = VQCTCFinetuneModel(s2u_cfg.model, trainer=None)
53
+ self.decoder = SynthesizerTrn(
54
+ u2s_cfg.num_symbols,
55
+ u2s_cfg.data.filter_length // 2 + 1,
56
+ u2s_cfg.train.segment_size // u2s_cfg.data.hop_length,
57
+ n_speakers=u2s_cfg.data.n_speakers,
58
+ **u2s_cfg.model
59
+ )
60
+ self.style_embedding = nn.Embedding(config.u2s_num_styles, config.u2s_dim_styles)
61
+
62
+ @property
63
+ def device(self):
64
+ return next(self.encoder.parameters()).device
65
+
66
+ @property
67
+ def dtype(self):
68
+ return next(self.encoder.parameters()).dtype
69
+
70
+ def encode(self, wav_file):
71
+ speech_unit = s2u_extract_unit_demo(self.encoder, wav_file, model_name='SPIRAL-FSQ-CTC', reduced=True)
72
+ return speech_unit
73
+
74
+ def decode(self, speech_unit, condition=None, output_wav_file='output.wav'):
75
+ content_unit = speech_unit.replace('<|speech_', '').replace('|>', ' ').strip()
76
+ style_centroid_embedding = self.style_embedding(torch.LongTensor([self.config.u2s_style2idx[condition]]).to(self.device)).unsqueeze(-1) if condition else None
77
+ audio = synthesis(content_unit, style_centroid_embedding, self.u2s_config, self.decoder, output_wav_file)
78
+ return audio