ProgramComputer commited on
Commit
56bb6b0
1 Parent(s): 6541e65

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +10 -4
test.py CHANGED
@@ -35,6 +35,7 @@ import zipfile
35
 
36
  import traceback
37
  import fsspec as fs
 
38
 
39
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
40
 
@@ -162,7 +163,7 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
162
  if self.config.name.startswith("audio"):
163
  features["speaker_name"] = datasets.Value("string")
164
  features["speaker_nationality"] = datasets.Value("string")
165
- features["audio"] = datasets.Audio()
166
  if self.config.name.startswith("video"):
167
  features["video"] = datasets.Value("large_binary")
168
 
@@ -332,11 +333,16 @@ class VoxCeleb(datasets.GeneratorBasedBuilder):
332
  info["speaker_name"] = speaker_info["VGGFace1 ID"]
333
  info["speaker_nationality"] = speaker_info["Nationality"]
334
  if conf.startswith("audio"):
335
- info["audio"] = info["file"]
 
 
 
 
 
 
336
  if conf.startswith("video"):
337
  with fs.open(info["file"], 'rb') as f:
338
- #buffer = BytesIO()
339
- #f.write(buffer)
340
  info["video"] = BytesIO(f.read()).getvalue()
341
  yield key, info
342
  key += 1
 
35
 
36
  import traceback
37
  import fsspec as fs
38
+ import librosa
39
 
40
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
41
 
 
163
  if self.config.name.startswith("audio"):
164
  features["speaker_name"] = datasets.Value("string")
165
  features["speaker_nationality"] = datasets.Value("string")
166
+ features["audio"] = datasets.Audio(mono=False)
167
  if self.config.name.startswith("video"):
168
  features["video"] = datasets.Value("large_binary")
169
 
 
333
  info["speaker_name"] = speaker_info["VGGFace1 ID"]
334
  info["speaker_nationality"] = speaker_info["Nationality"]
335
  if conf.startswith("audio"):
336
+ if dataset_format == "m4a":
337
+ y, sr = librosa.load(info["file"])
338
+ info["audio"] = {'array':y,'path':info["file"],'sampling_rate':sr}
339
+ else:
340
+ info["audio"] = info["file"]
341
+
342
+
343
  if conf.startswith("video"):
344
  with fs.open(info["file"], 'rb') as f:
345
+
 
346
  info["video"] = BytesIO(f.read()).getvalue()
347
  yield key, info
348
  key += 1