Skip to content

Commit

Permalink
整理: speaker_inforesources/character_info へ移動 (VOICEVOX#1353)
Browse files Browse the repository at this point in the history
* refactor: `resources/character_info` へ移動

* refactor: `speaker_info` を `resources/character_info` へ変更

* fix: キャラクターディレクトリの後方互換性を追加

* fix: リネーム反映忘れを修正

* Apply suggestions from code review

---------

Co-authored-by: Hiroshiba <[email protected]>
  • Loading branch information
tarepan and Hiroshiba authored Jun 2, 2024
1 parent ce90ca5 commit b10fb4c
Show file tree
Hide file tree
Showing 68 changed files with 15 additions and 12 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ ADD ./run.py ./presets.yaml ./engine_manifest.json /opt/voicevox_engine/
ADD ./resources /opt/voicevox_engine/resources
ADD ./build_util/generate_licenses.py /opt/voicevox_engine/build_util/
ADD ./build_util/licenses /opt/voicevox_engine/build_util/licenses
ADD ./speaker_info /opt/voicevox_engine/speaker_info

# Replace version
ARG VOICEVOX_ENGINE_VERSION=latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ VOICEVOX ENGINE リポジトリを fork し、一部の機能を改造するの
音声合成手法によっては、例えばモーフィング機能など、VOICEVOX と同じ機能を持つことができない場合があります。
その場合はマニフェストファイル内の`supported_features`内の情報を適宜変更してください。

キャラクター情報は`speaker_info`ディレクトリ内のファイルで管理されています。
キャラクター情報は`resources/character_info`ディレクトリ内のファイルで管理されています。
ダミーのアイコンなどが用意されているので適宜変更してください。

音声合成は`voicevox_engine/tts_pipeline/tts_engine.py`で行われています。
Expand Down
6 changes: 3 additions & 3 deletions build_util/process_voicevox_resource.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ if [ ! -v DOWNLOAD_RESOURCE_PATH ]; then
fi

# ダミーのキャラクター情報を置き換える
rm -r speaker_info
cp -r "${DOWNLOAD_RESOURCE_PATH}/character_info" speaker_info
rm -r resources/character_info
cp -r "${DOWNLOAD_RESOURCE_PATH}/character_info" resources/character_info

# キャラクター情報を前処理する
python "${DOWNLOAD_RESOURCE_PATH}/scripts/clean_character_info.py" \
--character_info_dir speaker_info/
--character_info_dir resources/character_info/

# エンジンマニフェストに含まれるダミーの情報を上書きする
jq -s '.[0] * .[1]' engine_manifest.json "${DOWNLOAD_RESOURCE_PATH}/engine/engine_manifest.json" \
Expand Down
5 changes: 4 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ def main() -> None:
else:
disable_mutable_api = decide_boolean_from_env("VV_DISABLE_MUTABLE_API")

speaker_info_dir = root_dir / "speaker_info"
speaker_info_dir = root_dir / "resources" / "character_info"
# NOTE: ENGINE v0.19 以前向けに後方互換性を確保する
if not speaker_info_dir.exists():
speaker_info_dir = root_dir / "speaker_info"

# ASGI に準拠した VOICEVOX ENGINE アプリケーションを生成する
app = generate_app(
Expand Down
1 change: 0 additions & 1 deletion run.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import os

datas = [
('resources', 'resources'),
('speaker_info', 'speaker_info'),
('engine_manifest.json', '.'),
('licenses.json', '.'),
('presets.yaml', '.'),
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark/engine_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _generate_engine_fake_server(root_dir: Path) -> TestClient:
core_manager=core_manager,
setting_loader=setting_loader,
preset_manager=preset_manager,
speaker_info_dir=root_dir / "speaker_info",
speaker_info_dir=root_dir / "resources" / "character_info",
user_dict=user_dict,
engine_manifest=engine_manifest,
)
Expand Down
2 changes: 1 addition & 1 deletion test/test_library_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setUp(self) -> None:
self.vvlib_manifest = json.loads(f.read())
self.library_uuid = self.vvlib_manifest["uuid"]
with ZipFile(self.library_filename, "w") as zf:
speaker_infos = glob.glob("speaker_info/**", recursive=True)
speaker_infos = glob.glob("resources/character_info/**", recursive=True)
for info in speaker_infos:
zf.write(info)
zf.writestr(vvlib_manifest_name, json.dumps(self.vvlib_manifest))
Expand Down
2 changes: 1 addition & 1 deletion voicevox_engine/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_app(
) -> FastAPI:
"""ASGI 'application' 仕様に準拠した VOICEVOX ENGINE アプリケーションインスタンスを生成する。"""
if speaker_info_dir is None:
speaker_info_dir = engine_root() / "speaker_info"
speaker_info_dir = engine_root() / "resources" / "character_info"

app = FastAPI(
title=engine_manifest.name,
Expand Down
2 changes: 1 addition & 1 deletion voicevox_engine/app/routers/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _speaker_info(
) -> SpeakerInfo:
# エンジンに含まれる話者メタ情報は、次のディレクトリ構造に従わなければならない:
# {root_dir}/
# speaker_info/
# character_info/
# {speaker_uuid_0}/
# policy.md
# portrait.png
Expand Down
4 changes: 3 additions & 1 deletion voicevox_engine/library/library_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def downloadable_libraries(self) -> list[DownloadableLibraryInfo]:
) as f:
libraries = json.load(f)
speaker_info = libraries[0]["speakers"][0]["speaker_info"]
mock_root_dir = Path("./speaker_info/7ffcb7ce-00ec-4bdc-82cd-45a8889e43ff")
mock_root_dir = Path(
"./resources/character_info/7ffcb7ce-00ec-4bdc-82cd-45a8889e43ff"
)
speaker_info["policy"] = (mock_root_dir / "policy.md").read_text()
speaker_info["portrait"] = base64.b64encode(
(mock_root_dir / "portrait.png").read_bytes()
Expand Down

0 comments on commit b10fb4c

Please sign in to comment.