ChazzyG/Retrieval-based-Voice-Conversion-WebUI
0
1import json2import re3 4# Define regular expression patterns5pattern = r"""i18n\([\s\n\t]*(["'][^"']+["'])[\s\n\t]*\)"""6 7# Initialize the dictionary to store key-value pairs8data = {}9 10 11def process(fn: str):12 global data13 with open(fn, "r", encoding="utf-8") as f:14 contents = f.read()15 matches = re.findall(pattern, contents)16 for key in matches:17 key = eval(key)18 print("extract:", key)19 data[key] = key20 21 22print("processing infer-web.py")23process("infer-web.py")24 25print("processing gui.py")26process("gui.py")27 28# Save as a JSON file29with open("./i18n/zh_CN.json", "w", encoding="utf-8") as f:30 json.dump(data, f, ensure_ascii=False, indent=4)31 f.write("\n")32 