Skip to content

Commit

Permalink
Fix: UserDictionary 初期化時にユーザー辞書の適用に失敗した際に発生する例外を適切にキャッチする
Browse files Browse the repository at this point in the history
多重起動時 Windows では user.dic がロックされているとかで読み込めないことがあるので、その対策
  • Loading branch information
tsukumijima committed Jan 4, 2025
1 parent 5fabdc1 commit 35f55c5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions voicevox_engine/user_dict/user_dict_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ def __init__(

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

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

@mutex_wrapper(mutex_user_dict)
Expand Down

0 comments on commit 35f55c5

Please sign in to comment.