Skip to content

Commit

Permalink
Update: pyopenjtalk を pyopenjtalk-dict に置き換え
Browse files Browse the repository at this point in the history
最近追加された r9y9/pyopenjtalk 本家のユーザー辞書機能を使うように変更した
ビルド済み wheel が直接インストールされるため、ビルド環境が不要になるメリットもある
  • Loading branch information
tsukumijima committed Mar 11, 2024
1 parent 0991be3 commit ae1c624
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 19 deletions.
69 changes: 53 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ soundfile = "^0.12.1"
pyyaml = "^6.0"
pyworld = "^0.3.0"
jinja2 = "^3.1.2" # NOTE: required by fastapi
pyopenjtalk = { git = "https://github.com/VOICEVOX/pyopenjtalk", rev = "b35fc89fe42948a28e33aed886ea145a51113f88" }
pyopenjtalk-dict = "^0.3.4.dev1"
semver = "^3.0.0"
platformdirs = "^3.10.0"
soxr = "^0.3.6"
Expand Down
4 changes: 2 additions & 2 deletions voicevox_engine/user_dict/user_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ def update_dict(
tmp_csv_path.write_text(csv_text, encoding="utf-8")

# 辞書.csvをOpenJTalk用にコンパイル
pyopenjtalk.create_user_dict(str(tmp_csv_path), str(tmp_compiled_path))
pyopenjtalk.mecab_dict_index(str(tmp_csv_path), str(tmp_compiled_path))
if not tmp_compiled_path.is_file():
raise RuntimeError("辞書のコンパイル時にエラーが発生しました。")

# コンパイル済み辞書の置き換え・読み込み
pyopenjtalk.unset_user_dict()
tmp_compiled_path.replace(compiled_dict_path)
if compiled_dict_path.is_file():
pyopenjtalk.set_user_dict(str(compiled_dict_path.resolve(strict=True)))
pyopenjtalk.update_global_jtalk_with_user_dict(str(compiled_dict_path.resolve(strict=True)))

except Exception as e:
print("Error: Failed to update dictionary.", file=sys.stderr)
Expand Down

0 comments on commit ae1c624

Please sign in to comment.