Wataru commited on
Commit
85481f1
·
verified ·
1 Parent(s): 4882af9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +20 -13
README.md CHANGED
@@ -1097,27 +1097,34 @@ Example (inside a `.tar` shard):
1097
  You can load the WebDataset directly with Hugging Face’s `datasets` library:
1098
 
1099
  ```python
1100
- import datasets
1101
- from IPython.display import Audio
1102
- from huggingface_hub import hf_hub_download
1103
- import yaml
 
 
1104
 
1105
- # Adjust the repo_id to your actual repository name
1106
- base_url = "[https://huggingface.co/datasets/sarulab-speech/yodas2_sidon/resolve/main/](https://huggingface.co/datasets/sarulab-speech/yodas2_sidon/resolve/main/)"
1107
- language = 'en000'
1108
- split = 'test'
1109
- data_file_path = hf_hub_download(repo_id="sarulab-speech/yodas2_sidon", repo_type="dataset", filename="paths.yaml")
1110
- paths = yaml.load(open(data_file_path, "r"), Loader=yaml.FullLoader)
1111
 
1112
- ds = datasets.load_dataset("webdataset", data_files=[base_url + p for p in paths['english'][split]],streaming=True)['train']
1113
 
1114
- sample = next(iter(ds))
 
 
 
 
 
 
1115
  audio = sample['flac']
1116
  print(sample['metadata.json'])
1117
  Audio(audio['array'], rate=audio['sampling_rate'])
1118
  ````
1119
 
1120
- Replace `language` with the desired language config (e.g., `english`, `german`).
1121
 
1122
  -----
1123
 
 
1097
  You can load the WebDataset directly with Hugging Face’s `datasets` library:
1098
 
1099
  ```python
1100
+ from datasets import load_dataset
1101
+ from huggingface_hub import list_repo_files
1102
+
1103
+ repo_id = "sarulab-speech/yodas2_sidon"
1104
+ subset="en000"
1105
+ all_files = list_repo_files(repo_id, repo_type="dataset")
1106
 
1107
+ urls = [
1108
+ f"https://huggingface.co/datasets/{repo_id}/resolve/main/{f}"
1109
+ for f in sorted(all_files)
1110
+ if f.endswith(".tar.gz") and f.startswith(subset)
1111
+ ]
 
1112
 
1113
+ print(f"Found {len(urls)} shards.")
1114
 
1115
+ dataset = load_dataset(
1116
+ "webdataset",
1117
+ data_files={"train": urls},
1118
+ streaming=True
1119
+ )['train']
1120
+ from IPython.display import Audio
1121
+ sample = next(iter(dataset))
1122
  audio = sample['flac']
1123
  print(sample['metadata.json'])
1124
  Audio(audio['array'], rate=audio['sampling_rate'])
1125
  ````
1126
 
1127
+ Replace `subset` with the desired subset.
1128
 
1129
  -----
1130