Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ description = "Add your description here"
readme = "README.md"
requires-python = "==3.11.9"
dependencies = [
"e2k==0.3.0",
"fastapi-slim>=0.115.5",
"jinja2>=3.1.3", # NOTE: required by fastapi.templating.Jinja2Templates (fastapi-slim's unmanaged dependency)
"kanalizer>=0.1.1",
"numpy>=2.2.3",
"platformdirs>=4.2.0",
"pydantic>=2.7.3",
Expand Down
2 changes: 1 addition & 1 deletion requirements-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ anyio==4.9.0
cffi==1.17.1
click==8.1.8
colorama==0.4.6 ; sys_platform == 'win32'
e2k==0.3.0
fastapi-slim==0.115.12
h11==0.14.0
idna==3.10
jinja2==3.1.6
kanalizer==0.1.1
macholib==1.16.3 ; sys_platform == 'darwin'
markupsafe==3.0.2
numpy==2.2.4
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cyclonedx-python-lib==9.1.0
defusedxml==0.7.1
distlib==0.3.9
docopt==0.6.2
e2k==0.3.0
fastapi-slim==0.115.12
filelock==3.18.0
h11==0.14.0
Expand All @@ -24,6 +23,7 @@ identify==2.6.9
idna==3.10
iniconfig==2.1.0
jinja2==3.1.6
kanalizer==0.1.1
license-expression==30.4.1
markdown-it-py==3.0.0
markupsafe==3.0.2
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ anyio==4.9.0
cffi==1.17.1
click==8.1.8
colorama==0.4.6 ; sys_platform == 'win32'
e2k==0.3.0
fastapi-slim==0.115.12
h11==0.14.0
idna==3.10
jinja2==3.1.6
kanalizer==0.1.1
markupsafe==3.0.2
numpy==2.2.4
platformdirs==4.3.7
Expand Down
1 change: 0 additions & 1 deletion run.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ datas = [
('engine_manifest.json', '.'),
('licenses.json', '.'),
]
datas += collect_data_files('e2k')
datas += collect_data_files('pyopenjtalk')

core_model_dir_path = os.environ.get('CORE_MODEL_DIR_PATH')
Expand Down

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

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

2 changes: 1 addition & 1 deletion test/unit/tts_pipeline/test_katakana_english.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ def test_convert_english_to_katakana() -> None:

pron = convert_english_to_katakana(string)

expected_pron = "ボイボ"
expected_pron = "ヴォイヴォ"

assert expected_pron == pron
18 changes: 17 additions & 1 deletion tools/generate_licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import argparse
import importlib.metadata
import json
import subprocess
import sys
Expand Down Expand Up @@ -93,7 +94,6 @@ def _update_licenses(pip_licenses: list[_PipLicense]) -> list[_License]:
"""pip から取得したライセンス情報の抜けを補完する。"""
package_to_license_url: dict[str, str] = {
# "package_name": "https://license.adress.com/v0.0.0/LICENSE.txt",
"e2k": "https://raw.githubusercontent.com/Patchethium/e2k/refs/tags/0.3.0/LICENSE",
Comment thread
sevenc-nanashi marked this conversation as resolved.
}

updated_licenses = []
Expand Down Expand Up @@ -304,11 +304,27 @@ def _add_licenses_manually(licenses: list[_License]) -> None:
]


def _patch_licenses_manually(licenses: list[_License]) -> None:
"""手動でライセンス情報を修正する。"""
for license in licenses:
if license.package_name == "kanalizer":
# kanalizerのwheelをビルドするときに使ったライブラリの情報を追加する
for p in importlib.metadata.files("kanalizer"): # type: ignore
if p.name == "NOTICE.md":
notice_md = Path(p.locate())
break
else:
raise Exception("kanalizerのNOTICE.mdが見つかりませんでした。")
license.license_text += "\n\n"
license.license_text += notice_md.read_text(encoding="utf-8")


def _generate_licenses() -> list[_License]:
pip_licenses = _acquire_licenses_of_pip_managed_libraries()
licenses = _update_licenses(pip_licenses)
_validate_license_compliance(licenses)
_add_licenses_manually(licenses)
_patch_licenses_manually(licenses)

return licenses

Expand Down
32 changes: 17 additions & 15 deletions uv.lock
Comment thread
sevenc-nanashi marked this conversation as resolved.

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

20 changes: 4 additions & 16 deletions voicevox_engine/tts_pipeline/katakana_english.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,11 @@
import re
from typing import NewType, TypeGuard

import e2k
import kanalizer

# 半角アルファベット文字列を示す型
HankakuAlphabet = NewType("HankakuAlphabet", str)

_global_c2k: e2k.C2K | None = None


def _initialize_c2k() -> e2k.C2K:
global _global_c2k
if _global_c2k is None:
_global_c2k = e2k.C2K()

return _global_c2k


# OpenJTalkで使っているアルファベット→カタカナの対応表
# https://github.com/VOICEVOX/open_jtalk/blob/b9b1bf6a0cba6bc9550b4521913b20334a218dfc/src/njd_set_pronunciation/njd_set_pronunciation_rule_utf_8.h#L397
Expand Down Expand Up @@ -69,19 +59,17 @@ def should_convert_english_to_katakana(string: HankakuAlphabet) -> bool:


def convert_english_to_katakana(string: HankakuAlphabet) -> str:
"""e2kを用いて、読みが不明な英単語をカタカナに変換する"""
c2k = _initialize_c2k()

"""kanalizerを用いて、読みが不明な英単語をカタカナに変換する"""
kana = ""
# キャメルケース的な単語に対応させるため、大文字で分割する
for word in re.findall("[a-zA-Z][a-z]*", string):
word = HankakuAlphabet(word)

# 大文字のみ、もしくは短いワードの場合は、e2kでの解析を行わない
# 大文字のみ、もしくは短いワードの場合は、kanalizerでの変換を行わない
if not should_convert_english_to_katakana(word):
for alphabet in word:
kana += ojt_alphabet_kana_mapping[alphabet.upper()]
else:
kana += c2k(word.lower())
kana += kanalizer.convert(word.lower())

return kana