Aybee5 commited on
Commit
958260d
·
verified ·
1 Parent(s): 9671f65

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +58 -23
README.md CHANGED
@@ -13,6 +13,11 @@ tags:
13
  - audio
14
  - multi-speaker
15
  pretty_name: Hausa TTS Dataset
 
 
 
 
 
16
  ---
17
 
18
  # Hausa TTS Dataset (HausaTTSEmbed)
@@ -52,42 +57,72 @@ Each example contains:
52
 
53
  ## Usage
54
 
55
- ### Basic Loading - Simple and Clean! 🎉
56
 
57
- All audio files are in the `data/` directory, so they auto-download with the dataset:
58
 
59
  ```python
 
60
  from datasets import load_dataset, Audio
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- # Load dataset - automatically downloads parquet AND audio files
63
- dataset = load_dataset("Aybee5/HausaTTSEmbed", split="train")
64
 
65
- # Cast audio column to enable audio loading
66
  dataset = dataset.cast_column("audio", Audio(sampling_rate=22050))
67
 
68
- print(f"Loaded {len(dataset)} samples")
69
 
70
- # Access first sample - audio is already downloaded!
71
  sample = dataset[0]
72
  print(f"Text: {sample['text']}")
73
- print(f"Speaker: {sample['speaker_id']}")
74
  print(f"Audio shape: {sample['audio']['array'].shape}")
75
- print(f"Sample rate: {sample['audio']['sampling_rate']}")
76
  ```
77
 
78
- **No manual downloads needed!** Audio files download automatically because they're in the `data/` directory.
79
 
80
- ### For Unsloth TTS Training
81
-
82
- Perfect for Unsloth - just plug and play:
83
 
84
  ```python
 
85
  from datasets import load_dataset, Audio
 
 
 
 
 
 
 
 
 
86
 
87
- # Load dataset (auto-downloads everything)
88
- raw_ds = load_dataset("Aybee5/HausaTTSEmbed", split="train")
 
 
 
 
 
 
 
89
 
90
- # Speaker handling (Unsloth's exact code)
91
  speaker_key = "source"
92
  if "source" not in raw_ds.column_names and "speaker_id" not in raw_ds.column_names:
93
  print("Unsloth: No speaker found, adding default source")
@@ -96,22 +131,22 @@ if "source" not in raw_ds.column_names and "speaker_id" not in raw_ds.column_nam
96
  elif "source" not in raw_ds.column_names and "speaker_id" in raw_ds.column_names:
97
  speaker_key = "speaker_id"
98
 
99
- # Resample to target sample rate
100
  target_sampling_rate = 24000
101
  raw_ds = raw_ds.cast_column("audio", Audio(sampling_rate=target_sampling_rate))
102
 
103
- # Optional: Split into train/validation
 
 
104
  split_ds = raw_ds.train_test_split(test_size=0.1, seed=42)
105
  train_ds = split_ds['train']
106
  val_ds = split_ds['test']
107
 
108
- print(f"Train: {len(train_ds)}, Validation: {len(val_ds)}")
109
-
110
- # Ready to train! No FileNotFoundError! 🎉
111
- processed_ds = raw_ds.map(preprocess_example, ...)
112
  ```
113
 
114
- **Works in Colab, Kaggle, and anywhere else!** No special configuration needed.
115
 
116
  ### With Transformers
117
 
 
13
  - audio
14
  - multi-speaker
15
  pretty_name: Hausa TTS Dataset
16
+ configs:
17
+ - config_name: default
18
+ data_files:
19
+ - split: train
20
+ path: data/**
21
  ---
22
 
23
  # Hausa TTS Dataset (HausaTTSEmbed)
 
57
 
58
  ## Usage
59
 
60
+ ### Recommended: Download All Files First
61
 
62
+ To ensure all audio files are available, download the entire dataset first:
63
 
64
  ```python
65
+ from huggingface_hub import snapshot_download
66
  from datasets import load_dataset, Audio
67
+ import os
68
+
69
+ # Download entire dataset (parquet + all audio files)
70
+ print("Downloading dataset (~2GB)...")
71
+ local_dir = snapshot_download(
72
+ "Aybee5/HausaTTSEmbed",
73
+ repo_type="dataset",
74
+ local_dir="hausa_tts_data"
75
+ )
76
+
77
+ # Load from downloaded files
78
+ dataset = load_dataset(
79
+ "parquet",
80
+ data_files=f"{local_dir}/data/*.parquet",
81
+ split="train"
82
+ )
83
 
84
+ # Fix audio paths to absolute paths
85
+ dataset = dataset.map(lambda x: {"audio": os.path.join(local_dir, x["audio"]), **x})
86
 
87
+ # Cast to Audio type
88
  dataset = dataset.cast_column("audio", Audio(sampling_rate=22050))
89
 
90
+ print(f"Loaded {len(dataset)} samples")
91
 
92
+ # Access sample
93
  sample = dataset[0]
94
  print(f"Text: {sample['text']}")
 
95
  print(f"Audio shape: {sample['audio']['array'].shape}")
 
96
  ```
97
 
98
+ ### For Unsloth TTS Training (Complete Code)
99
 
100
+ Use this complete code in your Unsloth/Colab notebook:
 
 
101
 
102
  ```python
103
+ from huggingface_hub import snapshot_download
104
  from datasets import load_dataset, Audio
105
+ import os
106
+
107
+ # Step 1: Download entire dataset
108
+ print("Downloading Hausa TTS dataset...")
109
+ local_dir = snapshot_download(
110
+ "Aybee5/HausaTTSEmbed",
111
+ repo_type="dataset",
112
+ local_dir="/content/hausa_tts" # Use /content/ for Colab
113
+ )
114
 
115
+ # Step 2: Load from downloaded files
116
+ raw_ds = load_dataset(
117
+ "parquet",
118
+ data_files=f"{local_dir}/data/*.parquet",
119
+ split="train"
120
+ )
121
+
122
+ # Step 3: Fix audio paths
123
+ raw_ds = raw_ds.map(lambda x: {"audio": os.path.join(local_dir, x["audio"]), **x})
124
 
125
+ # Step 4: Speaker handling (Unsloth's exact code)
126
  speaker_key = "source"
127
  if "source" not in raw_ds.column_names and "speaker_id" not in raw_ds.column_names:
128
  print("Unsloth: No speaker found, adding default source")
 
131
  elif "source" not in raw_ds.column_names and "speaker_id" in raw_ds.column_names:
132
  speaker_key = "speaker_id"
133
 
134
+ # Step 5: Resample to target sample rate
135
  target_sampling_rate = 24000
136
  raw_ds = raw_ds.cast_column("audio", Audio(sampling_rate=target_sampling_rate))
137
 
138
+ print(f"✓ Dataset ready: {len(raw_ds)} samples")
139
+
140
+ # Step 6: Optional - Split into train/validation
141
  split_ds = raw_ds.train_test_split(test_size=0.1, seed=42)
142
  train_ds = split_ds['train']
143
  val_ds = split_ds['test']
144
 
145
+ # Step 7: Continue with your Unsloth training!
146
+ # processed_ds = raw_ds.map(preprocess_example, ...)
 
 
147
  ```
148
 
149
+ This will work without FileNotFoundError! 🎉
150
 
151
  ### With Transformers
152