Repository: huggingface/datasets
File: datasets/librispeech_asr/librispeech_asr.py (Python)

Code before:

    def _generate_examples(self, files):
        """Generate examples from a LibriSpeech archive_path."""
        key = 0
        audio_data = {}
        transcripts = []
        for subset, iterator in files.items():
            for path, f in iterator:
                if path.endswith(".flac"):
                    id_ = path.split("/")[-1][: -len(".flac")]
                    audio_data[id_] = f.read()
                elif path.endswith(".trans.txt"):
                    for line in f:
                        if line:
                            line = line.decode("utf-8").strip()
                            id_, transcript = line.split(" ", 1)
                            audio_file = f"{id_}.flac"
                            speaker_id, chapter_id = [int(el) for el in id_.split("-")[:2]]
                            transcripts.append(
                                {
                                    "id": id_,
                                    "speaker_id": speaker_id,
                                    "chapter_id": chapter_id,
                                    "file": audio_file,
                                    "text": transcript,
                                    "subset": subset,
                                }
                            )
                if audio_data and len(audio_data) == len(transcripts):
                    for transcript in transcripts:
                        audio = {"path": transcript["file"], "bytes": audio_data[transcript["id"]]}
                        yield key, {"audio": audio, **transcript}
                        key += 1
                    audio_data = {}
                    transcripts = []


Review comment (suggestion):
@albertz @lhoestq - this "subset" arg is one of "clean-100", "clean-360", "other-500" for:

```python
ds = load_dataset("librispeech_asr", "all", split="train")
ds[0]
```

This should allow the user to easily define which subsets are needed I think

Code after:
                ),
                datasets.SplitGenerator(
                    name="train.other.500",
                    gen_kwargs={
                        "local_extracted_archive": local_extracted_archive.get("train.other.500"),
                        "files": dl_manager.iter_archive(archive_path["train.other.500"]),
                    },
                ),
            ]
            dev_splits = [
                datasets.SplitGenerator(
                    name="validation.clean",
                    gen_kwargs={
                        "local_extracted_archive": local_extracted_archive.get("validation.clean"),
                        "files": dl_manager.iter_archive(archive_path["dev.clean"]),
                    },
                ),
                datasets.SplitGenerator(
                    name="validation.other",
                    gen_kwargs={
                        "local_extracted_archive": local_extracted_archive.get("validation.other"),
                        "files": dl_manager.iter_archive(archive_path["dev.other"]),
                    },
                ),
            ]
            test_splits = [
                datasets.SplitGenerator(
                    name="test.clean",
                    gen_kwargs={
                        "local_extracted_archive": local_extracted_archive.get("test.clean"),
                        "files": dl_manager.iter_archive(archive_path["test.clean"]),
                    },
                ),
                datasets.SplitGenerator(
                    name="test.other",
                    gen_kwargs={
                        "local_extracted_archive": local_extracted_archive.get("test.other"),
                        "files": dl_manager.iter_archive(archive_path["test.other"]),
                    },
                ),
            ]

        return train_splits + dev_splits + test_splits

    def _generate_examples(self, files, local_extracted_archive):
        """Generate examples from a LibriSpeech archive_path."""
        key = 0
        audio_data = {}
        transcripts = []
        for path, f in files:
            if path.endswith(".flac"):