sanchit-gandhi commited on
Commit
fc2ce3c
·
1 Parent(s): e77dbf3

file ids - transcriptions

Browse files
Files changed (1) hide show
  1. spgispeech.py +7 -10
spgispeech.py CHANGED
@@ -77,9 +77,9 @@ _META_FILENAMES = {
77
  "test": "test.csv",
78
  }
79
 
80
- _WHISPER_TRANSCRIPT_URL = "https://huggingface.co/datasets/distil-whisper/spgispeech/resolve/main/transcription_data/greedy_search/"
81
 
82
- _WHISPER_TRANSCRIPT_URLs = _WHISPER_TRANSCRIPT_URL + "/{split}-transcription.txt"
83
 
84
 
85
  class Spgispeech(datasets.GeneratorBasedBuilder):
@@ -208,13 +208,11 @@ class Spgispeech(datasets.GeneratorBasedBuilder):
208
  csvreader = csv.DictReader(f, delimiter="|")
209
  metadata = {x["wav_filename"]: dict((k, x[k]) for k in dict_keys) for x in csvreader}
210
 
211
- whisper_transcripts = []
212
-
213
  with open(whisper_transcript, encoding="utf-8") as f:
214
- for row in f:
215
- whisper_transcripts.append(row.rstrip("\n"))
216
-
217
- idx = 0
218
 
219
  for local_extracted_archive_path, archive in zip(local_extracted_archive_paths, archives):
220
  # Here we iterate over all the files within the TAR archive:
@@ -233,6 +231,5 @@ class Spgispeech(datasets.GeneratorBasedBuilder):
233
  example["id"] = example.pop("wav_filename")
234
  example["text"] = example.pop("transcript")
235
  example["audio"] = {"path": path, "bytes": audio_file.read()}
236
- example["whisper_transcript"] = whisper_transcripts[idx]
237
  yield audio_filename, example
238
- idx += 1
 
77
  "test": "test.csv",
78
  }
79
 
80
+ _WHISPER_TRANSCRIPT_URL = "https://huggingface.co/datasets/distil-whisper/whisper_transcriptions_greedy/resolve/main/spgispeech"
81
 
82
+ _WHISPER_TRANSCRIPT_URLs = _WHISPER_TRANSCRIPT_URL + "/{split}-transcription.csv"
83
 
84
 
85
  class Spgispeech(datasets.GeneratorBasedBuilder):
 
208
  csvreader = csv.DictReader(f, delimiter="|")
209
  metadata = {x["wav_filename"]: dict((k, x[k]) for k in dict_keys) for x in csvreader}
210
 
211
+ whisper_transcriptions = dict()
 
212
  with open(whisper_transcript, encoding="utf-8") as f:
213
+ reader = csv.DictReader(f, delimiter=",", quoting=csv.QUOTE_NONE)
214
+ for line in reader:
215
+ whisper_transcriptions[line["file_id"]] = line["whisper_transcript"]
 
216
 
217
  for local_extracted_archive_path, archive in zip(local_extracted_archive_paths, archives):
218
  # Here we iterate over all the files within the TAR archive:
 
231
  example["id"] = example.pop("wav_filename")
232
  example["text"] = example.pop("transcript")
233
  example["audio"] = {"path": path, "bytes": audio_file.read()}
234
+ example["whisper_transcript"] = whisper_transcriptions.get(example["id"], None)
235
  yield audio_filename, example