Everlyn commited on
Commit
4514bd2
·
verified ·
1 Parent(s): 84d6823

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +35 -35
README.md CHANGED
@@ -41,31 +41,24 @@ size_categories:
41
 
42
  | Property | Value |
43
  |----------|-------|
44
- | Format | WAV/MP3/MP4/M4A |
45
- | Sample Rate | 16 kHz |
46
  | Channels | Mono |
47
 
48
  ---
49
 
50
- ## Dataset Structure
51
 
52
- ```
53
- KenSpeech/
54
- ├── README.md
55
- ├── metadata.csv # Main dataset with audio paths and transcripts
56
- ├── transcripts_only.csv # Additional transcripts without audio
57
- ├── lexicon.csv # Pronunciation dictionary (31K+ words)
58
- └── audio/ # Audio files
59
- └── *.wav, *.mp3, *.mp4, *.m4a
60
- ```
61
 
62
- ## Metadata Schema
 
 
63
 
64
- The `metadata.csv` file contains:
65
 
66
  | Column | Type | Description |
67
  |--------|------|-------------|
68
- | file_name | string | Path to audio file (e.g., `audio/female_speaker_1_sample_261.mp4`) |
69
  | source_folder | string | Origin folder (`stt_dictionary` or `stt_transcripts`) |
70
  | gender | string | Speaker gender (`male` or `female`) |
71
  | speaker | string | Speaker identifier (`speaker_1`, `speaker_2`, etc.) |
@@ -75,7 +68,7 @@ The `metadata.csv` file contains:
75
 
76
  ```python
77
  {
78
- 'file_name': 'audio/female_speaker_1_sample_261.mp4',
79
  'source_folder': 'stt_dictionary',
80
  'gender': 'female',
81
  'speaker': 'speaker_1',
@@ -92,18 +85,16 @@ The `metadata.csv` file contains:
92
  ```python
93
  from datasets import load_dataset
94
 
95
- # Load the dataset (auto-detected as AudioFolder via metadata.csv)
96
  dataset = load_dataset("Kencorpus/KenSpeech")
97
 
98
- # Access samples
99
  sample = dataset['train'][0]
100
- print(sample)
101
- # {'file_name': 'audio/female_speaker_1_sample_261.mp4',
102
- # 'audio': {'path': '...', 'array': array([...]), 'sampling_rate': 16000},
103
- # 'source_folder': 'stt_dictionary',
104
- # 'gender': 'female',
105
- # 'speaker': 'speaker_1',
106
- # 'transcript': 'masaa mawili kabla basi kuwasili...'}
107
  ```
108
 
109
  ### Filtering by Gender
@@ -122,36 +113,45 @@ male_data = dataset['train'].filter(lambda x: x['gender'] == 'male')
122
  print(f"Male samples: {len(male_data)}")
123
  ```
124
 
125
- ### Iterating Over Samples
126
 
127
  ```python
128
  from datasets import load_dataset
 
129
 
 
130
  dataset = load_dataset("Kencorpus/KenSpeech")
131
 
132
- for sample in dataset['train']:
133
- audio_array = sample['audio']['array']
134
- sampling_rate = sample['audio']['sampling_rate']
135
- transcript = sample['transcript']
136
- gender = sample['gender']
137
- print(f"[{gender}] {transcript[:50]}...")
 
 
138
  ```
139
 
140
  ---
141
 
142
- ## Pronunciation Lexicon
143
 
144
- The `lexicon.csv` file contains over 31,000 Swahili words with their phonetic transcriptions.
 
 
145
 
146
  **Format:** `word,phoneme_sequence`
147
 
148
- **Example entries:**
149
  ```
150
  wanapaswa,W AH N AH P AH S W AH
151
  wanasema,W AH N AH S EH M AH
152
  wanataka,W AH N AH T AH K AH
153
  ```
154
 
 
 
 
 
155
  ---
156
 
157
  ## Speech Types
 
41
 
42
  | Property | Value |
43
  |----------|-------|
44
+ | Sampling Rate | 16 kHz |
 
45
  | Channels | Mono |
46
 
47
  ---
48
 
49
+ ## Dataset Format
50
 
51
+ The dataset is distributed as **Parquet files** with embedded audio for optimal compatibility:
 
 
 
 
 
 
 
 
52
 
53
+ - **Format**: Apache Parquet (with embedded audio bytes)
54
+ - **Encoding**: UTF-8 for text fields
55
+ - **Compatibility**: Works with `datasets` 4.0.0+ without custom loading scripts
56
 
57
+ ## Data Fields
58
 
59
  | Column | Type | Description |
60
  |--------|------|-------------|
61
+ | audio | Audio | Audio waveform (decoded array + sampling_rate) |
62
  | source_folder | string | Origin folder (`stt_dictionary` or `stt_transcripts`) |
63
  | gender | string | Speaker gender (`male` or `female`) |
64
  | speaker | string | Speaker identifier (`speaker_1`, `speaker_2`, etc.) |
 
68
 
69
  ```python
70
  {
71
+ 'audio': {'path': '...', 'array': array([0.001, -0.003, ...]), 'sampling_rate': 16000},
72
  'source_folder': 'stt_dictionary',
73
  'gender': 'female',
74
  'speaker': 'speaker_1',
 
85
  ```python
86
  from datasets import load_dataset
87
 
88
+ # Load the dataset
89
  dataset = load_dataset("Kencorpus/KenSpeech")
90
 
91
+ # Access a sample
92
  sample = dataset['train'][0]
93
+ print(sample['transcript'])
94
+ print(sample['gender'])
95
+ print(sample['speaker'])
96
+ print(sample['audio']['sampling_rate']) # 16000
97
+ print(sample['audio']['array'].shape) # audio waveform
 
 
98
  ```
99
 
100
  ### Filtering by Gender
 
113
  print(f"Male samples: {len(male_data)}")
114
  ```
115
 
116
+ ### Training an ASR Model
117
 
118
  ```python
119
  from datasets import load_dataset
120
+ from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
121
 
122
+ # Load dataset
123
  dataset = load_dataset("Kencorpus/KenSpeech")
124
 
125
+ # Load a multilingual model
126
+ model_name = "facebook/wav2vec2-large-xlsr-53"
127
+ processor = Wav2Vec2Processor.from_pretrained(model_name)
128
+ model = Wav2Vec2ForCTC.from_pretrained(model_name)
129
+
130
+ # Process a sample
131
+ sample = dataset['train'][0]
132
+ inputs = processor(sample['audio']['array'], sampling_rate=16000, return_tensors="pt")
133
  ```
134
 
135
  ---
136
 
137
+ ## Additional Resources
138
 
139
+ ### Pronunciation Lexicon (`lexicon.csv`)
140
+
141
+ A Swahili lexicon-phone dictionary with over 31,000 words and their phonetic transcriptions.
142
 
143
  **Format:** `word,phoneme_sequence`
144
 
 
145
  ```
146
  wanapaswa,W AH N AH P AH S W AH
147
  wanasema,W AH N AH S EH M AH
148
  wanataka,W AH N AH T AH K AH
149
  ```
150
 
151
+ ### Transcript-only Data (`transcripts_only.csv`)
152
+
153
+ Additional transcripts from the stt_transcripts collection without corresponding audio.
154
+
155
  ---
156
 
157
  ## Speech Types