KELONMYOSA commited on
Commit
918abe7
1 Parent(s): 6d3f4f4

fixed examples generation

Browse files
Files changed (1) hide show
  1. dusha.py +7 -7
dusha.py CHANGED
@@ -44,7 +44,7 @@ class Dusha(datasets.GeneratorBasedBuilder):
44
  )]
45
 
46
  def _generate_examples(self, audio_files: Union[str, os.PathLike], metadata: str):
47
- examples = list()
48
 
49
  with open(metadata) as f:
50
  for row in f:
@@ -54,11 +54,11 @@ class Dusha(datasets.GeneratorBasedBuilder):
54
  res = dict()
55
  res["path"] = os.path.join(audio_files, audio_path)
56
  res["label"] = label
57
- examples.append(res)
58
 
59
  key = 0
60
- for example in examples:
61
- audio_file = open(example["path"])
62
- audio = {"path": example["path"], "bytes": audio_file.read()}
63
- yield key, {**example, "audio": audio}
64
- key += 1
 
44
  )]
45
 
46
  def _generate_examples(self, audio_files: Union[str, os.PathLike], metadata: str):
47
+ examples = dict()
48
 
49
  with open(metadata) as f:
50
  for row in f:
 
54
  res = dict()
55
  res["path"] = os.path.join(audio_files, audio_path)
56
  res["label"] = label
57
+ examples[audio_path] = res
58
 
59
  key = 0
60
+ for path, f in audio_files:
61
+ if path in examples:
62
+ audio = {"path": path, "bytes": f.read()}
63
+ yield key, {**examples[path], "audio": audio}
64
+ key += 1