Skip to content

Commit

Permalink
整理: root_dirspeaker_info_dirgenerate_app() 引数を変更 (#1340)
Browse files Browse the repository at this point in the history
refactor: `root_dir` → `speaker_info_dir` へ引数を変更

Co-authored-by: Hiroshiba Kazuyuki <[email protected]>
  • Loading branch information
tarepan and Hiroshiba authored May 29, 2024
1 parent 3149a19 commit bdc5ab8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
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 @@ -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,
)
Expand Down
12 changes: 7 additions & 5 deletions voicevox_engine/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions voicevox_engine/app/routers/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=["その他"])
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit bdc5ab8

Please sign in to comment.