From bdc5ab8488357fc8ead4ba097405dd792987e8b0 Mon Sep 17 00:00:00 2001 From: tarepan Date: Wed, 29 May 2024 18:04:54 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86:=20`root=5Fdir`=20=E2=86=92?= =?UTF-8?q?=20`speaker=5Finfo=5Fdir`=20=E3=81=B8=20`generate=5Fapp()`=20?= =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E5=A4=89=E6=9B=B4=20(#1340)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: `root_dir` → `speaker_info_dir` へ引数を変更 Co-authored-by: Hiroshiba Kazuyuki --- run.py | 4 +++- test/benchmark/engine_preparation.py | 2 +- voicevox_engine/app/application.py | 12 +++++++----- voicevox_engine/app/routers/speaker.py | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/run.py b/run.py index 4a60cf9a4..106f6491c 100644 --- a/run.py +++ b/run.py @@ -334,6 +334,8 @@ def main() -> None: else: disable_mutable_api = decide_boolean_from_env("VV_DISABLE_MUTABLE_API") + speaker_info_dir = root_dir / "speaker_info" + # ASGI に準拠した VOICEVOX ENGINE アプリケーションを生成する app = generate_app( tts_engines, @@ -344,7 +346,7 @@ def main() -> None: use_dict, engine_manifest, cancellable_engine, - root_dir, + speaker_info_dir, cors_policy_mode, allow_origin, disable_mutable_api=disable_mutable_api, diff --git a/test/benchmark/engine_preparation.py b/test/benchmark/engine_preparation.py index 059d2c791..98875c60a 100644 --- a/test/benchmark/engine_preparation.py +++ b/test/benchmark/engine_preparation.py @@ -35,7 +35,7 @@ def _generate_engine_fake_server(root_dir: Path) -> TestClient: latest_core_version=latest_core_version, setting_loader=setting_loader, preset_manager=preset_manager, - root_dir=root_dir, + speaker_info_dir=root_dir / "speaker_info", user_dict=user_dict, engine_manifest=engine_manifest, ) diff --git a/voicevox_engine/app/application.py b/voicevox_engine/app/application.py index d49c2d1b0..1782d2a6b 100644 --- a/voicevox_engine/app/application.py +++ b/voicevox_engine/app/application.py @@ -37,14 +37,14 @@ def generate_app( user_dict: UserDictionary, engine_manifest: EngineManifest, cancellable_engine: CancellableEngine | None = None, - root_dir: Path | None = None, + speaker_info_dir: Path | None = None, cors_policy_mode: CorsPolicyMode = CorsPolicyMode.localapps, allow_origin: list[str] | None = None, disable_mutable_api: bool = False, ) -> FastAPI: """ASGI 'application' 仕様に準拠した VOICEVOX ENGINE アプリケーションインスタンスを生成する。""" - if root_dir is None: - root_dir = engine_root() + if speaker_info_dir is None: + speaker_info_dir = engine_root() / "speaker_info" app = FastAPI( title=engine_manifest.name, @@ -65,7 +65,7 @@ def generate_app( engine_manifest.uuid, ) - metas_store = MetasStore(root_dir / "speaker_info") + metas_store = MetasStore(speaker_info_dir) app.include_router( generate_tts_pipeline_router( @@ -74,7 +74,9 @@ def generate_app( ) app.include_router(generate_morphing_router(tts_engines, core_manager, metas_store)) app.include_router(generate_preset_router(preset_manager)) - app.include_router(generate_speaker_router(core_manager, metas_store, root_dir)) + app.include_router( + generate_speaker_router(core_manager, metas_store, speaker_info_dir) + ) if engine_manifest.supported_features.manage_library: app.include_router(generate_library_router(engine_manifest, library_manager)) app.include_router(generate_user_dict_router(user_dict)) diff --git a/voicevox_engine/app/routers/speaker.py b/voicevox_engine/app/routers/speaker.py index d62c3686e..080b6624a 100644 --- a/voicevox_engine/app/routers/speaker.py +++ b/voicevox_engine/app/routers/speaker.py @@ -22,7 +22,7 @@ def b64encode_str(s: bytes) -> str: def generate_speaker_router( core_manager: CoreManager, metas_store: MetasStore, - root_dir: Path, + speaker_info_dir: Path, ) -> APIRouter: """話者情報 API Router を生成する""" router = APIRouter(tags=["その他"]) @@ -87,7 +87,7 @@ def _speaker_info( # 話者情報を取得する try: - speaker_path = root_dir / "speaker_info" / speaker_uuid + speaker_path = speaker_info_dir / speaker_uuid # speaker policy policy_path = speaker_path / "policy.md"