dlxj
commited on
Commit
•
1d399e7
1
Parent(s):
388a1c1
- rebuild_dataset.py +23 -1
rebuild_dataset.py
CHANGED
@@ -1,4 +1,26 @@
|
|
1 |
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
+
import glob, os, re
|
3 |
+
from pathlib import Path
|
4 |
+
pth_wavs = glob.glob('/mnt/y/ai/Genshin_Dataset/Genshin4.8_JP/**/*.wav', recursive=True)
|
5 |
|
6 |
+
array = []
|
7 |
|
8 |
+
for idx, pth_wav in enumerate(pth_wavs):
|
9 |
+
speaker = re.compile('Japanese\/(.+?)\/').search(pth_wav).group(1)
|
10 |
+
speaker = re.compile('[#「」]').sub("", speaker)
|
11 |
+
# if speaker != 'Unknown':
|
12 |
+
# print(speaker)
|
13 |
+
|
14 |
+
pth_lab = Path(os.path.dirname(pth_wav)) / (Path(pth_wav).stem +'.lab')
|
15 |
+
if pth_lab.exists():
|
16 |
+
with open(pth_lab.resolve(), encoding='utf-8') as f:
|
17 |
+
s = f.read()
|
18 |
+
s = s.strip()
|
19 |
+
if s:
|
20 |
+
array.append( { "wav": pth_wav, "speaker":speaker, "transcription":s } )
|
21 |
+
|
22 |
+
if (idx+1) % 100 == 0:
|
23 |
+
print( f"{idx+1} / {len(pth_wavs)}" )
|
24 |
+
break
|
25 |
+
|
26 |
+
pass
|