cdminix commited on
Commit
c96e05d
·
verified ·
1 Parent(s): a781096

Update libriheavy.py

Browse files
Files changed (1) hide show
  1. libriheavy.py +59 -15
libriheavy.py CHANGED
@@ -54,6 +54,7 @@ class Libriheavy(datasets.GeneratorBasedBuilder):
54
  {
55
  "id": datasets.Value("string"),
56
  "speaker_id": datasets.Value("string"),
 
57
  "audio": datasets.Value("string"),
58
  "text": datasets.Value("string"),
59
  "word_segments": datasets.Sequence(
@@ -71,6 +72,22 @@ class Libriheavy(datasets.GeneratorBasedBuilder):
71
  }
72
  ),
73
  "mel_spectrogram": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
  ),
76
  supervised_keys=None,
@@ -153,10 +170,11 @@ class Libriheavy(datasets.GeneratorBasedBuilder):
153
  # skip the last utterance
154
  if utterance_id == sorted(list(text.keys()))[-1]:
155
  continue
156
- print(npz[str(utterance_id)].item().keys())
157
  result = {
158
  "id": chunk["speaker_id"] + "_" + utterance_id,
159
  "speaker_id": chunk["speaker_id"],
 
160
  "audio": chunk["audio"],
161
  "text": chunk["text"],
162
  "word_segments": [
@@ -165,24 +183,50 @@ class Libriheavy(datasets.GeneratorBasedBuilder):
165
  "phone_segments": [
166
  {"start": segment[0], "end": segment[1], "phone": segment[2]} for segment in utterance["phone_segments"]
167
  ],
168
- "mel_spectrogram": npz[str(utterance_id)].item()["mel"][0][0],
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
170
  yield chunk["speaker_id"] + "_" + utterance_id, result
171
  else:
172
  # only use the last utterance
173
  utterance_id = sorted(list(text.keys()))[-1]
174
  utterance = text[utterance_id]
175
- result = {
176
- "id": chunk["speaker_id"] + "_" + utterance_id,
177
- "speaker_id": chunk["speaker_id"],
178
- "audio": chunk["audio"],
179
- "text": chunk["text"],
180
- "word_segments": [
181
- {"start": segment[0], "end": segment[1], "word": segment[2]} for segment in utterance["word_segments"]
182
- ],
183
- "phone_segments": [
184
- {"start": segment[0], "end": segment[1], "phone": segment[2]} for segment in utterance["phone_segments"]
185
- ],
186
- "mel_spectrogram": npz[str(utterance_id)].item()["mel"][0][0],
187
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  yield chunk["speaker_id"] + "_" + utterance_id, result
 
54
  {
55
  "id": datasets.Value("string"),
56
  "speaker_id": datasets.Value("string"),
57
+ "speaker_vec": datasets.Sequence(datasets.Value("float32")),
58
  "audio": datasets.Value("string"),
59
  "text": datasets.Value("string"),
60
  "word_segments": datasets.Sequence(
 
72
  }
73
  ),
74
  "mel_spectrogram": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
75
+ "attributes": datasets.Sequence(
76
+ {
77
+ "pitch": datasets.Sequence(datasets.Value("float32")),
78
+ "energy": datasets.Sequence(datasets.Value("float32")),
79
+ "snr": datasets.Sequence(datasets.Value("float32")),
80
+ "srmr": datasets.Sequence(datasets.Value("float32")),
81
+ }
82
+ ),
83
+ "overall_attributes": datasets.Sequence(
84
+ {
85
+ "pitch": datasets.Value("float32"),
86
+ "energy": datasets.Value("float32"),
87
+ "snr": datasets.Value("float32"),
88
+ "srmr": datasets.Value("float32"),
89
+ }
90
+ ),
91
  }
92
  ),
93
  supervised_keys=None,
 
170
  # skip the last utterance
171
  if utterance_id == sorted(list(text.keys()))[-1]:
172
  continue
173
+ npz_item = npz[str(utterance_id)].item()
174
  result = {
175
  "id": chunk["speaker_id"] + "_" + utterance_id,
176
  "speaker_id": chunk["speaker_id"],
177
+ "speaker_vec": npz_item["d_vector"],
178
  "audio": chunk["audio"],
179
  "text": chunk["text"],
180
  "word_segments": [
 
183
  "phone_segments": [
184
  {"start": segment[0], "end": segment[1], "phone": segment[2]} for segment in utterance["phone_segments"]
185
  ],
186
+ "mel_spectrogram": npz_item["mel"][0][0],
187
+ "attributes": {
188
+ npz_item["pitch"],
189
+ npz_item["energy"],
190
+ npz_item["snr"],
191
+ npz_item["srmr"],
192
+ },
193
+ "overall_attributes": {
194
+ npz_item["overall_pitch"],
195
+ npz_item["overall_energy"],
196
+ npz_item["overall_snr"],
197
+ npz_item["overall_srmr"],
198
+ },
199
  }
200
  yield chunk["speaker_id"] + "_" + utterance_id, result
201
  else:
202
  # only use the last utterance
203
  utterance_id = sorted(list(text.keys()))[-1]
204
  utterance = text[utterance_id]
205
+ npz_item = npz[str(utterance_id)].item()
206
+ result = {
207
+ "id": chunk["speaker_id"] + "_" + utterance_id,
208
+ "speaker_id": chunk["speaker_id"],
209
+ "speaker_vec": npz_item["d_vector"],
210
+ "audio": chunk["audio"],
211
+ "text": chunk["text"],
212
+ "word_segments": [
213
+ {"start": segment[0], "end": segment[1], "word": segment[2]} for segment in utterance["word_segments"]
214
+ ],
215
+ "phone_segments": [
216
+ {"start": segment[0], "end": segment[1], "phone": segment[2]} for segment in utterance["phone_segments"]
217
+ ],
218
+ "mel_spectrogram": npz_item["mel"][0][0],
219
+ "attributes": {
220
+ npz_item["pitch"],
221
+ npz_item["energy"],
222
+ npz_item["snr"],
223
+ npz_item["srmr"],
224
+ },
225
+ "overall_attributes": {
226
+ npz_item["overall_pitch"],
227
+ npz_item["overall_energy"],
228
+ npz_item["overall_snr"],
229
+ npz_item["overall_srmr"],
230
+ },
231
+ }
232
  yield chunk["speaker_id"] + "_" + utterance_id, result