common_voice_17_0 / rebuild_dataset.py
dlxj
add reame.txt
f6ed4dc
raw
history blame
1.22 kB
# Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s16, 768 kb/s
"""
rm -rf ~/.cache/huggingface/datasets/dlxjj___common_voice_17_0 &&
rm -rf ~/.cache/huggingface/modules/datasets_modules/datasets/dlxjj--common_voice_17_0 &&
rm -rf ~/.cache/huggingface/modules/datasets_modules/datasets/dlxjj--common_voice_17_0.lock &&
rm -rf ~/.cache/huggingface/datasets/downloads &&
rm -rf ~/.cache/huggingface/hub/datasets--dlxjj--common_voice_17_0
"""
# 更新数据集后先删除缓存
import glob, os, re
from pathlib import Path
pth_wavs = glob.glob('/mnt/y/ai/Genshin_Dataset/Genshin4.8_JP/**/*.wav', recursive=True)
array = []
for idx, pth_wav in enumerate(pth_wavs):
if "带变量语音" in pth_wav:
continue
speaker = re.compile('Japanese\/(.+?)\/').search(pth_wav).group(1)
speaker = re.compile('[#「」]').sub("", speaker)
pth_lab = Path(os.path.dirname(pth_wav)) / (Path(pth_wav).stem +'.lab')
if pth_lab.exists():
with open(pth_lab.resolve(), encoding='utf-8') as f:
s = f.read()
s = s.strip()
if s:
array.append( { "wav": pth_wav, "speaker":speaker, "transcription":s } )
if (idx+1) % 100 == 0:
print( f"{idx+1} / {len(pth_wavs)}" )
break
pass