system HF staff commited on
Commit
00947c0
1 Parent(s): 0611d17

Update files from the datasets library (from 1.10.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.10.0

Files changed (2) hide show
  1. README.md +2 -2
  2. librispeech_asr.py +12 -11
README.md CHANGED
@@ -17,9 +17,9 @@ size_categories:
17
  source_datasets:
18
  - original
19
  task_categories:
20
- - automatic-speech-recognition
21
  task_ids:
22
- - speech-recognition
23
  ---
24
 
25
  # Dataset Card for librispeech_asr
 
17
  source_datasets:
18
  - original
19
  task_categories:
20
+ - speech-processing
21
  task_ids:
22
+ - automatic-speech-recognition
23
  ---
24
 
25
  # Dataset Card for librispeech_asr
librispeech_asr.py CHANGED
@@ -135,21 +135,22 @@ class LibrispeechASR(datasets.GeneratorBasedBuilder):
135
  ]
136
 
137
  def _generate_examples(self, archive_path):
138
- """Generate examples from a Librispeech archive_path."""
139
  transcripts_glob = os.path.join(archive_path, "LibriSpeech", "*/*/*/*.txt")
140
- for transcript_file in sorted(glob.glob(transcripts_glob)):
141
- path = os.path.dirname(transcript_file)
142
- with open(os.path.join(path, transcript_file), "r", encoding="utf-8") as f:
 
143
  for line in f:
144
  line = line.strip()
145
- key, transcript = line.split(" ", 1)
146
- audio_file = f"{key}.flac"
147
- speaker_id, chapter_id = [int(el) for el in key.split("-")[:2]]
148
- example = {
149
- "id": key,
150
  "speaker_id": speaker_id,
151
  "chapter_id": chapter_id,
152
- "file": os.path.join(path, audio_file),
153
  "text": transcript,
154
  }
155
- yield key, example
 
135
  ]
136
 
137
  def _generate_examples(self, archive_path):
138
+ """Generate examples from a LibriSpeech archive_path."""
139
  transcripts_glob = os.path.join(archive_path, "LibriSpeech", "*/*/*/*.txt")
140
+ key = 0
141
+ for transcript_path in sorted(glob.glob(transcripts_glob)):
142
+ transcript_dir_path = os.path.dirname(transcript_path)
143
+ with open(transcript_path, "r", encoding="utf-8") as f:
144
  for line in f:
145
  line = line.strip()
146
+ id_, transcript = line.split(" ", 1)
147
+ audio_file = f"{id_}.flac"
148
+ speaker_id, chapter_id = [int(el) for el in id_.split("-")[:2]]
149
+ yield key, {
150
+ "id": id_,
151
  "speaker_id": speaker_id,
152
  "chapter_id": chapter_id,
153
+ "file": os.path.join(transcript_dir_path, audio_file),
154
  "text": transcript,
155
  }
156
+ key += 1