albertvillanova HF staff commited on
Commit
bc3ee03
1 Parent(s): fe550f4

Fix DuplicatedKeysError in timit_asr dataset (#4424)

Browse files

* Fix DuplicatedKeysError in timit_asr dataset

* Refactor

* Update dataset card

Commit from https://github.com/huggingface/datasets/commit/b8c9790174ecb057fed3c993dddcd3becb46619e

Files changed (2) hide show
  1. README.md +1 -1
  2. timit_asr.py +2 -2
README.md CHANGED
@@ -170,7 +170,7 @@ A typical data point comprises the path to the audio file, usually called `file`
170
 
171
  - speaker_id: Unique id of the speaker. The same speaker id can be found for multiple data samples.
172
 
173
- - id: Unique id of the data sample. Contains the <SENTENCE_TYPE><SENTENCE_NUMBER>.
174
 
175
 
176
  ### Data Splits
 
170
 
171
  - speaker_id: Unique id of the speaker. The same speaker id can be found for multiple data samples.
172
 
173
+ - id: ID of the data sample. Contains the <SENTENCE_TYPE><SENTENCE_NUMBER>.
174
 
175
 
176
  ### Data Splits
timit_asr.py CHANGED
@@ -129,7 +129,7 @@ class TimitASR(datasets.GeneratorBasedBuilder):
129
  def _generate_examples(self, split, data_dir):
130
  """Generate examples from TIMIT archive_path based on the test/train csv information."""
131
  # Iterating the contents of the data to extract the relevant information
132
- for wav_path in sorted(Path(data_dir).glob(f"**/{split.upper()}/**/*.WAV")):
133
 
134
  # extract transcript
135
  with open(wav_path.with_suffix(".TXT"), encoding="utf-8") as op:
@@ -174,4 +174,4 @@ class TimitASR(datasets.GeneratorBasedBuilder):
174
  "id": id_,
175
  }
176
 
177
- yield id_, example
 
129
  def _generate_examples(self, split, data_dir):
130
  """Generate examples from TIMIT archive_path based on the test/train csv information."""
131
  # Iterating the contents of the data to extract the relevant information
132
+ for key, wav_path in enumerate(sorted(Path(data_dir).glob(f"**/{split.upper()}/**/*.WAV"))):
133
 
134
  # extract transcript
135
  with open(wav_path.with_suffix(".TXT"), encoding="utf-8") as op:
 
174
  "id": id_,
175
  }
176
 
177
+ yield key, example