indiejoseph commited on
Commit
5f7dac2
·
verified ·
1 Parent(s): 37542cb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -3
README.md CHANGED
@@ -1,3 +1,45 @@
1
- ---
2
- license: cc0-1.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc0-1.0
3
+ ---
4
+
5
+ # 張悦楷三國演義
6
+
7
+ Fork from [laubonghaudoi/zoengjyutgaai_saamgwokjinji](https://huggingface.co/datasets/laubonghaudoi/zoengjyutgaai_saamgwokjinji)
8
+
9
+ We found the original wav files are not splitted correctly, so we asked the author to provide the srt file and un-splitted wav files. We then re-split the wav files and align the srt file to the wav files.
10
+
11
+ ```python
12
+ subtitles = []
13
+ splits = librosa.effects.split(audio) # shape: (682, 2)
14
+
15
+ !mkdir -p dataset/zoengjyutgaai_saamgwokjinji/wavs
16
+
17
+ # split audio by srt time
18
+ for i, sub in enumerate(subs):
19
+ chunk_start = sub.start.to_time()
20
+ chunk_end = sub.end.to_time()
21
+ chunk_start = ((chunk_start.minute * 60) + chunk_start.second) * sr
22
+ chunk_end = ((chunk_end.minute * 60) + chunk_end.second) * sr
23
+
24
+ # Find the closest split
25
+ chunk_start = min(splits, key=lambda x: abs(x[0] - chunk_start))[0]
26
+ chunk_end = min(splits, key=lambda x: abs(x[1] - chunk_end))[1]
27
+
28
+ chunk = audio[chunk_start:chunk_end]
29
+ wav_file = f"001_{i:03}.wav"
30
+
31
+ # resample, since bert-vits2 training only support 44.1k
32
+ try:
33
+ chunk = librosa.resample(chunk, sr, 44100)
34
+ except:
35
+ print(f"Error resampling {wav_file}")
36
+ continue
37
+
38
+ subtitles.append({ 'path': wav_file, 'speaker': 'zoengjyutgaai', 'language': 'YUE', 'text': sub.text })
39
+
40
+ # export audio
41
+ sf.write(f"dataset/zoengjyutgaai_saamgwokjinji/wavs/{wav_file}", chunk, 44100, subtype='PCM_16')
42
+
43
+ df = pd.DataFrame(subtitles)
44
+ df.to_csv("dataset/zoengjyutgaai_saamgwokjinji/001.csv", index=False, sep='|', header=False)
45
+ ```