sanchit-gandhi HF staff commited on
Commit
8f44d63
1 Parent(s): 99bede6

Fix streaming mode bug

Browse files

Currently, streaming mode is broken with People's Speech. E.g. trying to stream the "train" split of the "clean" subset, we expect to iterate over ~12k hours of audio data, corresponding to 4481 shards of audio data. However, streaming terminates after only just 1005 audio samples. Since the number of audio samples is less than the number of shards, we're clearly missing data:

```python
from datasets import load_dataset

peoples_speech = load_dataset("MLCommons/peoples_speech", "clean", split="train", streaming=True)

# iterate over the entire 'train' split of the 'clean' subset
for i, sample in enumerate(peoples_speech):
continue

# how many samples do we have?
print(i)
```
**Print output:**
```
1005
```

The problem is that we set `local_extracted_archive = [None] * len(audio_archive_paths)`, where `audio_archive_paths`is a dictionary mapping from split to audio shard paths. This means that `audio_archive_paths` has length 3 (train, validation, test), and so we always set `local_extracted_archive = [None, None, None]`. In reality, it should be set to a list as long as the number of shards we have _per split_, i.e. for the train split: `local_extracted_archive = [None] * 4481`, or equivalently `local_extracted_archive = [None] * len(audio_archive_paths["train"])`.

Files changed (1) hide show
  1. peoples_speech.py +1 -1
peoples_speech.py CHANGED
@@ -157,7 +157,7 @@ class PeoplesSpeech(datasets.GeneratorBasedBuilder):
157
  # In non-streaming mode, we extract the archives to have the data locally:
158
  local_extracted_archive_paths = dl_manager.extract(audio_archive_paths) \
159
  if not dl_manager.is_streaming else \
160
- {split: [None] * len(audio_archive_paths) for split in splits_to_configs}
161
 
162
  manifest_urls = {
163
  split: _MANIFEST_URL.format(split=split, config=config) for split, config in splits_to_configs.items()
 
157
  # In non-streaming mode, we extract the archives to have the data locally:
158
  local_extracted_archive_paths = dl_manager.extract(audio_archive_paths) \
159
  if not dl_manager.is_streaming else \
160
+ {split: [None] * len(audio_archive_paths[split]) for split in splits_to_configs}
161
 
162
  manifest_urls = {
163
  split: _MANIFEST_URL.format(split=split, config=config) for split, config in splits_to_configs.items()