Skip to content

Commit 35f55c5

Browse files
committed
Fix: UserDictionary 初期化時にユーザー辞書の適用に失敗した際に発生する例外を適切にキャッチする
多重起動時 Windows では user.dic がロックされているとかで読み込めないことがあるので、その対策
1 parent 5fabdc1 commit 35f55c5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

voicevox_engine/user_dict/user_dict_manager.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,15 @@ def __init__(
105105

106106
# サーバーの起動高速化のため、前回起動時にビルド済みのユーザー辞書データがあれば、そのまま pyopenjtalk に適用する
107107
if self._compiled_dict_path.is_file():
108-
pyopenjtalk.update_global_jtalk_with_user_dict(
109-
str(self._compiled_dict_path.resolve(strict=True))
110-
)
111-
logger.info("Compiled user dictionary applied.")
108+
try:
109+
pyopenjtalk.update_global_jtalk_with_user_dict(
110+
str(self._compiled_dict_path.resolve(strict=True))
111+
)
112+
logger.info("Compiled user dictionary applied.")
113+
except Exception as ex:
114+
logger.error("Failed to apply compiled user dictionary.", exc_info=ex)
112115

113-
# バックグラウンドで辞書更新を行う (数秒程度を要する)
116+
# バックグラウンドで辞書更新を行う (辞書登録量によっては数秒を要する)
114117
threading.Thread(target=self.update_dict, daemon=True).start()
115118

116119
@mutex_wrapper(mutex_user_dict)

0 commit comments

Comments
 (0)