From 793b0043deb59f67c1d019f9caf3da4e1e625770 Mon Sep 17 00:00:00 2001 From: wjd <65559675+wjddd@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:30:57 +0800 Subject: [PATCH] Fix g2pw bug (#1872) --- GPT_SoVITS/text/g2pw/g2pw.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/GPT_SoVITS/text/g2pw/g2pw.py b/GPT_SoVITS/text/g2pw/g2pw.py index 1e3738a..e81b24d 100644 --- a/GPT_SoVITS/text/g2pw/g2pw.py +++ b/GPT_SoVITS/text/g2pw/g2pw.py @@ -144,11 +144,16 @@ def read_dict(): return polyphonic_dict -def correct_pronunciation(word,word_pinyins): - if word in pp_dict: - word_pinyins = pp_dict[word] - - return word_pinyins +def correct_pronunciation(word, word_pinyins): + new_pinyins = pp_dict.get(word, "") + if new_pinyins == "": + for idx, w in enumerate(word): + w_pinyin = pp_dict.get(w, "") + if w_pinyin != "": + word_pinyins[idx] = w_pinyin[0] + return word_pinyins + else: + return new_pinyins pp_dict = get_dict()