Datasets:
Update files from the datasets library (from 1.10.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.10.0
- README.md +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 |
-
-
|
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
|
139 |
transcripts_glob = os.path.join(archive_path, "LibriSpeech", "*/*/*/*.txt")
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
143 |
for line in f:
|
144 |
line = line.strip()
|
145 |
-
|
146 |
-
audio_file = f"{
|
147 |
-
speaker_id, chapter_id = [int(el) for el in
|
148 |
-
|
149 |
-
"id":
|
150 |
"speaker_id": speaker_id,
|
151 |
"chapter_id": chapter_id,
|
152 |
-
"file": os.path.join(
|
153 |
"text": transcript,
|
154 |
}
|
155 |
-
|
|
|
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
|