fix #73: 伴奏人声分离时报错:FileNotFoundError (#74)

* fix #73: 伴奏人声分离时报错:FileNotFoundError

* Apply Code Formatter Change

---------

Co-authored-by: fumiama <fumiama@users.noreply.github.com>
This commit is contained in:
源文雨 2023-04-16 17:30:32 +08:00 committed by GitHub
parent 6fb458a754
commit 13da7b3f96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -7,7 +7,9 @@ standard_file = "zh_CN.json"
# Find all JSON files in the directory # Find all JSON files in the directory
dir_path = "./" dir_path = "./"
languages = [f for f in os.listdir(dir_path) if f.endswith(".json") and f != standard_file] languages = [
f for f in os.listdir(dir_path) if f.endswith(".json") and f != standard_file
]
# Load the standard file # Load the standard file
with open(standard_file, "r", encoding="utf-8") as f: with open(standard_file, "r", encoding="utf-8") as f:
@ -35,8 +37,8 @@ for lang_file in languages:
# Sort the keys of the language file to match the order of the standard file # Sort the keys of the language file to match the order of the standard file
lang_data = OrderedDict( lang_data = OrderedDict(
sorted(lang_data.items(), key=lambda x: list(standard_data.keys()).index(x[0])) sorted(lang_data.items(), key=lambda x: list(standard_data.keys()).index(x[0]))
) )
# Save the updated language file # Save the updated language file
with open(lang_file, "w", encoding="utf-8") as f: with open(lang_file, "w", encoding="utf-8") as f:
json.dump(lang_data, f, ensure_ascii=False, indent=4) json.dump(lang_data, f, ensure_ascii=False, indent=4)

View File

@ -4,7 +4,7 @@ from tqdm import tqdm
import json import json
def load_data(file_name: str = "./uvr5_pack/data.json") -> dict: def load_data(file_name: str = "./uvr5_pack/name_params.json") -> dict:
with open(file_name, "r") as f: with open(file_name, "r") as f:
data = json.load(f) data = json.load(f)