laubonghaudoi commited on
Commit
b65ea89
·
1 Parent(s): 39616d7

Add script to convert opus files to wav format

Browse files
Files changed (2) hide show
  1. README.md +67 -36
  2. to_wav.sh +22 -0
README.md CHANGED
@@ -1,48 +1,48 @@
1
  ---
2
  language:
3
- - yue
4
  license: cc0-1.0
5
  size_categories:
6
- - 10K<n<100K
7
  task_categories:
8
- - automatic-speech-recognition
9
- - text-to-speech
10
- - text-generation
11
- - feature-extraction
12
- - audio-to-audio
13
- - audio-classification
14
- - text-to-audio
15
  pretty_name: c
16
  configs:
17
- - config_name: default
18
- data_files:
19
- - split: saamgwokjinji
20
- path: data/saamgwokjinji-*
21
- - split: seoiwuzyun
22
- path: data/seoiwuzyun-*
23
  tags:
24
- - cantonese
25
- - audio
26
- - art
27
  dataset_info:
28
  features:
29
- - name: audio
30
- dtype: audio
31
- - name: id
32
- dtype: string
33
- - name: episode_id
34
- dtype: int64
35
- - name: audio_duration
36
- dtype: float64
37
- - name: transcription
38
- dtype: string
39
  splits:
40
- - name: saamgwokjinji
41
- num_bytes: 2398591354.589
42
- num_examples: 39173
43
- - name: seoiwuzyun
44
- num_bytes: 1243416911.25
45
- num_examples: 18881
46
  download_size: 3690072406
47
  dataset_size: 3642008265.839
48
  ---
@@ -73,6 +73,7 @@ TTS 效果演示:https://huggingface.co/spaces/laubonghaudoi/zoengjyutgaai_tts
73
  - 所有文本都使用全角標點,冇半角標點。
74
  - 所有文本都用漢字轉寫,無阿拉伯數字無英文字母
75
  - 所有音頻源都存放喺`/source`,為方便直接用作訓練數據,切分後嘅音頻都放喺 `opus/`
 
76
  - 所有源字幕 SRT 文件都存放喺 `srt/` 路經下,搭配 `source/` 下嘅音源可以直接作為帶字幕嘅錄音直接欣賞。
77
  - `cut.py` 係切分腳本,將對應嘅音源根據 srt 切分成短句並生成一個文本轉寫 csv。
78
  - `stats.py` 係統計腳本,運行佢就會顯示成個數據集嘅各項統計數據。
@@ -152,10 +153,17 @@ ffmpeg -i webm/saamgwokjinji/001.webm -c:a copy source/saamgwokjinji/001.opus
152
  # 或者轉 mp3
153
  ffmpeg -i mp3/mouzaakdung/001.mp3 -c:a libopus -map_metadata -1 -b:a 48k -vbr on source/mouzaakdung/001.opus
154
  # 將 opus 轉成無損 wav
155
- ffmpeg -i source/saamgwokjinji/001.opus -c:a copy wav/saamgwokjinji/001.wav
156
  ```
157
 
158
- 本數據集所有 opus 音頻皆為 48000 Hz 採樣率。
 
 
 
 
 
 
 
159
 
160
  # The Zoeng Jyut Gaai Story-telling Speech Dataset
161
 
@@ -176,6 +184,7 @@ TTS demo: https://huggingface.co/spaces/laubonghaudoi/zoengjyutgaai_tts
176
  - All transcriptions use full-width punctuations, no half-width punctuations is used.
177
  - All transcriptions are in Chinese characters, no Arabic numbers or Latin letters.
178
  - All source audio are stored in `source/`. For the convenice of training, segmented audios are stored in `opus/`.
 
179
  - All source subtitle SRT files are stored in `srt/`. Use them with the webm files to enjoy subtitled storytelling pieces.
180
  - `cut.py` is the script for cutting opus audios into senteneces based on the srt, and generates a csv file for transcriptions.
181
  - `stats.py` is the script for getting stats of this dataset.
@@ -215,3 +224,25 @@ git sparse-checkout set opus
215
  # Pull the content
216
  git pull origin main
217
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  language:
3
+ - yue
4
  license: cc0-1.0
5
  size_categories:
6
+ - 10K<n<100K
7
  task_categories:
8
+ - automatic-speech-recognition
9
+ - text-to-speech
10
+ - text-generation
11
+ - feature-extraction
12
+ - audio-to-audio
13
+ - audio-classification
14
+ - text-to-audio
15
  pretty_name: c
16
  configs:
17
+ - config_name: default
18
+ data_files:
19
+ - split: saamgwokjinji
20
+ path: data/saamgwokjinji-*
21
+ - split: seoiwuzyun
22
+ path: data/seoiwuzyun-*
23
  tags:
24
+ - cantonese
25
+ - audio
26
+ - art
27
  dataset_info:
28
  features:
29
+ - name: audio
30
+ dtype: audio
31
+ - name: id
32
+ dtype: string
33
+ - name: episode_id
34
+ dtype: int64
35
+ - name: audio_duration
36
+ dtype: float64
37
+ - name: transcription
38
+ dtype: string
39
  splits:
40
+ - name: saamgwokjinji
41
+ num_bytes: 2398591354.589
42
+ num_examples: 39173
43
+ - name: seoiwuzyun
44
+ num_bytes: 1243416911.25
45
+ num_examples: 18881
46
  download_size: 3690072406
47
  dataset_size: 3642008265.839
48
  ---
 
73
  - 所有文本都使用全角標點,冇半角標點。
74
  - 所有文本都用漢字轉寫,無阿拉伯數字無英文字母
75
  - 所有音頻源都存放喺`/source`,為方便直接用作訓練數據,切分後嘅音頻都放喺 `opus/`
76
+ - 所有 opus 音頻皆為 48000 Hz 採樣率。
77
  - 所有源字幕 SRT 文件都存放喺 `srt/` 路經下,搭配 `source/` 下嘅音源可以直接作為帶字幕嘅錄音直接欣賞。
78
  - `cut.py` 係切分腳本,將對應嘅音源根據 srt 切分成短句並生成一個文本轉寫 csv。
79
  - `stats.py` 係統計腳本,運行佢就會顯示成個數據集嘅各項統計數據。
 
153
  # 或者轉 mp3
154
  ffmpeg -i mp3/mouzaakdung/001.mp3 -c:a libopus -map_metadata -1 -b:a 48k -vbr on source/mouzaakdung/001.opus
155
  # 將 opus 轉成無損 wav
156
+ ffmpeg -i source/saamgwokjinji/001.opus wav/saamgwokjinji/001.wav
157
  ```
158
 
159
+ 如果想將所有 opus 文件全部轉換成 wav,可以直接運行`to_wav.sh`:
160
+
161
+ ```
162
+ chmod +x to_wav.sh
163
+ ./to_wav.sh
164
+ ```
165
+
166
+ 跟住就會生成一個 `wav/` 路經,入面都係 `opus/` 對應嘅音頻。注意 wav 格式非常掗埞,成個 `opus/` 轉晒後會佔用至少 500GB 儲存空間,所以轉換之前記得確保有足夠空間。如果你想對音頻重採樣,亦都可以修改 `to_wav.sh` 入面嘅命令順便做重採樣。
167
 
168
  # The Zoeng Jyut Gaai Story-telling Speech Dataset
169
 
 
184
  - All transcriptions use full-width punctuations, no half-width punctuations is used.
185
  - All transcriptions are in Chinese characters, no Arabic numbers or Latin letters.
186
  - All source audio are stored in `source/`. For the convenice of training, segmented audios are stored in `opus/`.
187
+ - All opus audio are in 48000 Hz sampling rate.
188
  - All source subtitle SRT files are stored in `srt/`. Use them with the webm files to enjoy subtitled storytelling pieces.
189
  - `cut.py` is the script for cutting opus audios into senteneces based on the srt, and generates a csv file for transcriptions.
190
  - `stats.py` is the script for getting stats of this dataset.
 
224
  # Pull the content
225
  git pull origin main
226
  ```
227
+
228
+ ### Audio format conversion
229
+
230
+ Install [ffmpeg](https://www.ffmpeg.org/download.html) first, then run:
231
+
232
+ ```bash
233
+ # convert all webm into opus
234
+ ffmpeg -i webm/saamgwokjinji/001.webm -c:a copy source/saamgwokjinji/001.opus
235
+ # or into mp3
236
+ ffmpeg -i mp3/mouzaakdung/001.mp3 -c:a libopus -map_metadata -1 -b:a 48k -vbr on source/mouzaakdung/001.opus
237
+ # convert all opus into loseless wav
238
+ ffmpeg -i source/saamgwokjinji/001.opus wav/saamgwokjinji/001.wav
239
+ ```
240
+
241
+ If you want to convert all opus to wav, run `to_wav.sh`:
242
+
243
+ ```
244
+ chmod +x to_wav.sh
245
+ ./to_wav.sh
246
+ ```
247
+
248
+ It will generate a `wav/` path which contains all audios converted from `opus/`. Be aware the wav format is very space-consuming. A full conversion will take up at least 500GB space so make sure you have enough storage. If you want to resample the audio, modify the line within `to_wav.sh` to resample the audio while doing the conversion.
to_wav.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Create the wav directory if it doesn't exist
4
+ mkdir -p wav
5
+
6
+ # Find all .opus files in the opus directory and loop through them
7
+ find opus/ -name "*.opus" -print0 | while IFS= read -r -d $'\0' opus_file; do
8
+ # Construct the corresponding .wav file path
9
+ wav_file=$(echo "$opus_file" | sed 's|opus/|wav/|; s|\.opus$|\.wav|')
10
+
11
+ # Create the subdirectory in wav/ if it doesn't exist
12
+ mkdir -p "$(dirname "$wav_file")"
13
+
14
+ # Convert the .opus file to .wav using ffmpeg, preserving original quality
15
+ ffmpeg -i "$opus_file" "$wav_file"
16
+ # Uncomment the line below to resample to 44100 Hz
17
+ # ffmpeg -i "$opus_file" -ar 44100 "$wav_file"
18
+
19
+ echo "Converted: $opus_file -> $wav_file"
20
+ done
21
+
22
+ echo "Conversion complete."