From 7e66149757785f355ef3a9194bd68e162ad051ad Mon Sep 17 00:00:00 2001 From: Ding Junyao <11372753+DingJunyao@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:37:53 +0800 Subject: [PATCH] fix: encoding err when extracting text BERT features because of no encoding setting in open() --- GPT_SoVITS/text/chinese.py | 2 +- GPT_SoVITS/text/chinese2.py | 2 +- GPT_SoVITS/text/english.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GPT_SoVITS/text/chinese.py b/GPT_SoVITS/text/chinese.py index 944c9cb7..271dbf04 100644 --- a/GPT_SoVITS/text/chinese.py +++ b/GPT_SoVITS/text/chinese.py @@ -13,7 +13,7 @@ normalizer = lambda x: cn2an.transform(x, "an2cn") current_file_path = os.path.dirname(__file__) pinyin_to_symbol_map = { line.split("\t")[0]: line.strip().split("\t")[1] - for line in open(os.path.join(current_file_path, "opencpop-strict.txt")).readlines() + for line in open(os.path.join(current_file_path, "opencpop-strict.txt"), encoding="utf-8").readlines() } import jieba_fast diff --git a/GPT_SoVITS/text/chinese2.py b/GPT_SoVITS/text/chinese2.py index acfebfe2..c076efea 100644 --- a/GPT_SoVITS/text/chinese2.py +++ b/GPT_SoVITS/text/chinese2.py @@ -14,7 +14,7 @@ normalizer = lambda x: cn2an.transform(x, "an2cn") current_file_path = os.path.dirname(__file__) pinyin_to_symbol_map = { line.split("\t")[0]: line.strip().split("\t")[1] - for line in open(os.path.join(current_file_path, "opencpop-strict.txt")).readlines() + for line in open(os.path.join(current_file_path, "opencpop-strict.txt"), encoding="utf-8").readlines() } import jieba_fast diff --git a/GPT_SoVITS/text/english.py b/GPT_SoVITS/text/english.py index f6c69449..be100665 100644 --- a/GPT_SoVITS/text/english.py +++ b/GPT_SoVITS/text/english.py @@ -131,7 +131,7 @@ def replace_consecutive_punctuation(text): def read_dict(): g2p_dict = {} start_line = 49 - with open(CMU_DICT_PATH) as f: + with open(CMU_DICT_PATH, encoding="utf-8") as f: line = f.readline() line_index = 1 while line: @@ -154,7 +154,7 @@ def read_dict(): def read_dict_new(): g2p_dict = {} - with open(CMU_DICT_PATH) as f: + with open(CMU_DICT_PATH, encoding="utf-8") as f: line = f.readline() line_index = 1 while line: @@ -167,7 +167,7 @@ def read_dict_new(): line_index = line_index + 1 line = f.readline() - with open(CMU_DICT_FAST_PATH) as f: + with open(CMU_DICT_FAST_PATH, encoding="utf-8") as f: line = f.readline() line_index = 1 while line: @@ -185,7 +185,7 @@ def read_dict_new(): def hot_reload_hot(g2p_dict): - with open(CMU_DICT_HOT_PATH) as f: + with open(CMU_DICT_HOT_PATH, encoding="utf-8") as f: line = f.readline() line_index = 1 while line: