Spaces:
Sleeping
Sleeping
''' | |
Author: Wxl | |
Date: 2024-03-13 15:39:46 | |
LastEditors: waysolong [email protected] | |
LastEditTime: 2024-03-13 15:41:25 | |
FilePath: \text_to_speech\data_dict.py | |
Description: | |
Copyright (c) 2024 by ${git_name} email: ${git_email}, All Rights Reserved. | |
''' | |
import os | |
import json | |
scp_file1 = "train\gp.scp" | |
with open(scp_file1, 'rt',encoding="utf-8") as f: | |
lines1 = f.read().split('\n') | |
scp_file2 = "train\py.scp" | |
res = {} | |
with open(scp_file2, 'rt',encoding="utf-8") as f: | |
lines2 = f.read().split('\n') | |
for line1,line2 in zip(lines1,lines2): | |
le1 = (line1.replace(" sil","").split(" ")[1:]) | |
le2 = (line2.replace(" sil","").split(" ")[1:]) | |
if len(le1)!=(len(le2)): | |
print(456) | |
else: | |
for l1,l2 in zip(le1,le2): | |
res[l1] = l2 | |
print(res) | |
with open("dict_han_pinyin.json","w",encoding="utf-8") as f: | |
json.dump(res,f,ensure_ascii=False,indent=4) | |