TenzinGayche commited on
Commit
cf48bc4
1 Parent(s): 019a5d9

generating data issue fixed

Browse files
Files changed (1) hide show
  1. tibetan_voice.py +31 -32
tibetan_voice.py CHANGED
@@ -105,35 +105,34 @@ class TibetanVoice(datasets.GeneratorBasedBuilder):
105
  datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["valid"],"wavs":wavs,'wavfilepath':downloaded_wav}),
106
  datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"],"wavs":wavs,'wavfilepath':downloaded_wav}),
107
  ]
108
- def _generate_examples(self, filepath, wavs, wavfilepath):
109
- """This function returns the examples in the raw (text) form."""
110
- example_map = {}
111
- logger.info("generating examples from = %s", filepath)
112
- with open(filepath, encoding="utf-8") as f:
113
- #tsv file
114
- reader = csv.reader(f, delimiter="\t", quotechar=None)
115
- next(reader)
116
- for row in reader:
117
- example_map[row["path"]] = row["sentence"]
118
-
119
-
120
-
121
- audio_map = {}
122
- for path, f in wavs:
123
- _, filename = os.path.split(path)
124
- audio_map[filename] = {"path": wavfilepath+'/'+path, "bytes": f.read()}
125
-
126
- for key, path in enumerate(example_map.keys()):
127
- _, filename = os.path.split(path)
128
- sentence = example_map.get(filename, "")
129
- audio = audio_map.get(filename, {})
130
- example = {
131
- "path": path,
132
- "sentence": sentence,
133
- "audio": audio
134
- }
135
- yield key, example
136
-
137
-
138
-
139
-
 
105
  datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["valid"],"wavs":wavs,'wavfilepath':downloaded_wav}),
106
  datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"],"wavs":wavs,'wavfilepath':downloaded_wav}),
107
  ]
108
+ def _generate_examples(self, filepath, wavs):
109
+
110
+ """This function returns the examples in the raw (text) form."""
111
+ example_map = {}
112
+ logger.info("generating examples from = %s", filepath)
113
+ with open(filepath, encoding="utf-8") as f:
114
+ reader = csv.reader(f, delimiter='\t')
115
+ for row in reader:
116
+ if len(row) >= 2:
117
+ path = row[0]
118
+ sentence = row[1]
119
+ example_map[path] = sentence
120
+
121
+ audio_map = {}
122
+ for path, f in wavs:
123
+ _, filename = os.path.split(path)
124
+ audio_map[filename] = {"path": path, "bytes": f.read()}
125
+
126
+ for key, path in enumerate(example_map.keys()):
127
+ _, filename = os.path.split(path)
128
+ sentence = example_map.get(filename, "")
129
+ audio = audio_map.get(filename, {})
130
+ example = {
131
+ "path": path,
132
+ "sentence": sentence,
133
+ "audio": audio
134
+ }
135
+ yield key, example
136
+
137
+
138
+