Anjaly commited on
Commit
8c004d0
1 Parent(s): 19b51eb

supporting audio zip files

Browse files
Files changed (1) hide show
  1. snow-mountain.py +12 -11
snow-mountain.py CHANGED
@@ -135,19 +135,20 @@ class Test(datasets.GeneratorBasedBuilder):
135
  key = 0
136
  with open(filepath) as f:
137
  data_df = pd.read_csv(f,sep=',')
138
- transcripts = []
139
  for index,row in data_df.iterrows():
140
  audio = row['path'].split('/')[-1]
141
- zip_url = '/'.join(row["path"].split('/')[:-1])+'.zip'
142
- archive_path = dl_manager.download(zip_url)
143
- # zip_f = zipfile.ZipFile(archive_path)
144
- # f = zip_f.open(audio)
145
- # content = f.read()
146
- for path, file in dl_manager.iter_archive(archive_path):
147
- content = file.read()
148
- # # if file in str(row["path"]):
149
- # # content = file.read()
150
- # # break
 
151
  yield key, {
152
  "sentence": row["sentence"],
153
  "path": row["path"],
 
135
  key = 0
136
  with open(filepath) as f:
137
  data_df = pd.read_csv(f,sep=',')
138
+ audio_data = {}
139
  for index,row in data_df.iterrows():
140
  audio = row['path'].split('/')[-1]
141
+ if audio in audio_data:
142
+ content = audio_data[audio]
143
+ else:
144
+ zip_url = '/'.join(row["path"].split('/')[:-1])+'.zip'
145
+ archive_path = dl_manager.download(zip_url)
146
+ for path, file in dl_manager.iter_archive(archive_path):
147
+ content = path.read()
148
+ # audio_data[audio] = content
149
+
150
+ # # if file in str(row["path"]):
151
+ # # content = file.read()
152
  yield key, {
153
  "sentence": row["sentence"],
154
  "path": row["path"],