diff --git a/run.py b/run.py index 2ba61d0c9..57fc3467a 100644 --- a/run.py +++ b/run.py @@ -11,7 +11,6 @@ import uvicorn from fastapi import FastAPI, HTTPException from fastapi.responses import HTMLResponse -from fastapi.templating import Jinja2Templates from voicevox_engine import __version__ from voicevox_engine.app.dependencies import deprecated_mutable_api @@ -120,12 +119,6 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]: metas_store = MetasStore(root_dir / "speaker_info") - setting_ui_template = Jinja2Templates( - directory=engine_root() / "ui_template", - variable_start_string="", - variable_end_string="", - ) - def get_engine(core_version: Optional[str]) -> TTSEngine: if core_version is None: return tts_engines[latest_core_version] @@ -157,11 +150,7 @@ def get_core(core_version: Optional[str]) -> CoreAdapter: app.include_router( generate_engine_info_router(get_core, cores, engine_manifest_data) ) - app.include_router( - generate_setting_router( - setting_loader, engine_manifest_data, setting_ui_template - ) - ) + app.include_router(generate_setting_router(setting_loader, engine_manifest_data)) @app.get("/", response_class=HTMLResponse, tags=["その他"]) async def get_portal() -> str: diff --git a/voicevox_engine/app/routers/setting.py b/voicevox_engine/app/routers/setting.py index f52855375..7207533de 100644 --- a/voicevox_engine/app/routers/setting.py +++ b/voicevox_engine/app/routers/setting.py @@ -8,14 +8,20 @@ from voicevox_engine.engine_manifest.EngineManifest import EngineManifest from voicevox_engine.setting.Setting import CorsPolicyMode, Setting from voicevox_engine.setting.SettingLoader import SettingHandler +from voicevox_engine.utility.path_utility import engine_root from ..dependencies import check_disabled_mutable_api +_setting_ui_template = Jinja2Templates( + directory=engine_root() / "ui_template", + variable_start_string="", + variable_end_string="", +) + def generate_setting_router( setting_loader: SettingHandler, engine_manifest_data: EngineManifest, - setting_ui_template: Jinja2Templates, ) -> APIRouter: """設定 API Router を生成する""" router = APIRouter() @@ -34,7 +40,7 @@ def setting_get(request: Request) -> Response: if allow_origin is None: allow_origin = "" - return setting_ui_template.TemplateResponse( + return _setting_ui_template.TemplateResponse( "ui.html", { "request": request,