diff --git a/config.py b/config.py index c6a4d90..54f8d17 100644 --- a/config.py +++ b/config.py @@ -263,7 +263,7 @@ with open(os.path.join("configs", "paths.yml"), "r", encoding="utf-8") as f: try: config = Config("config.yml", path_config) -except TypeError: +except (TypeError, KeyError): logger.warning("Old config.yml found. Replace it with default_config.yml.") shutil.copy(src="default_config.yml", dst="config.yml") config = Config("config.yml", path_config) diff --git a/text/japanese.py b/text/japanese.py index 75a8433..961a95d 100644 --- a/text/japanese.py +++ b/text/japanese.py @@ -8,6 +8,7 @@ from transformers import AutoTokenizer from text import punctuation, symbols from num2words import num2words +from common.log import logger import pyopenjtalk import jaconv @@ -21,14 +22,24 @@ def hiragana2p(text: str) -> str: - avoid using `N` for `ん` (for compatibility) """ # 3文字以上からなる変換規則 - text = text.replace("う゛ぁ", " b a") - text = text.replace("う゛ぃ", " b i") - text = text.replace("う゛ぇ", " b e") - text = text.replace("う゛ぉ", " b o") + text = text.replace("う゛ぁ", " v a") + text = text.replace("う゛ぃ", " v i") + text = text.replace("う゛ぇ", " v e") + text = text.replace("う゛ぉ", " v o") text = text.replace("う゛ゅ", " by u") + # ゔ等の処理を追加 + text = text.replace("ゔぁ", " v a") + text = text.replace("ゔぃ", " v i") + text = text.replace("ゔぇ", " v e") + text = text.replace("ゔぉ", " v o") + text = text.replace("ゔゅ", " by u") + # 2文字からなる変換規則 - text = text.replace("ぅ゛", " b u") + text = text.replace("ぅ゛", " v u") + + # ゔの処理を追加 + text = text.replace("ゔ", " v u") text = text.replace("あぁ", " a a") text = text.replace("いぃ", " i i") @@ -340,6 +351,7 @@ def hiragana2p(text: str) -> str: def kata2phoneme(text: str) -> str: """Convert katakana text to phonemes.""" + logger.debug(f"Kata2phoneme: {text}") text = text.strip() if text == "ー": return ["ー"] @@ -357,6 +369,9 @@ def kata2phoneme(text: str) -> str: res.append(prev[-1]) text = text[1:] continue + logger.debug(f"text: {text}") + logger.debug(jaconv.kata2hira(text)) + logger.debug(hiragana2p(jaconv.kata2hira(text))) res += hiragana2p(jaconv.kata2hira(text)).split(" ") break # res = _COLON_RX.sub(":", res) diff --git a/webui_train.py b/webui_train.py index be26df5..5fa450f 100644 --- a/webui_train.py +++ b/webui_train.py @@ -219,6 +219,13 @@ def preprocess_all( def train(model_name): dataset_path, _, _, _, config_path = get_path(model_name) + # 学習再開の場合は念のためconfig.ymlの名前等を更新 + with open("config.yml", "r", encoding="utf-8") as f: + yml_data = yaml.safe_load(f) + yml_data["model_name"] = model_name + yml_data["dataset_path"] = dataset_path + with open("config.yml", "w", encoding="utf-8") as f: + yaml.dump(yml_data, f, allow_unicode=True) success, message = run_script_with_log( ["train_ms.py", "--config", config_path, "--model", dataset_path] )