Skip to content

Commit

Permalink
整理: コアバージョン一覧を core_version_list 変数で管理 (#1447)
Browse files Browse the repository at this point in the history
* fix: `LATEST_VERSION` 利用忘れを修正

* refactor: コアバージョンを扱う `core_version_list` を追加

* fix: lint
  • Loading branch information
tarepan authored Jun 28, 2024
1 parent 2974aab commit f3e449f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion voicevox_engine/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def generate_app(
resource_manager = ResourceManager(is_development())
resource_manager.register_dir(character_info_dir)

core_version_list = core_manager.versions()

def _get_core_characters(version: str | None) -> list[CoreCharacter]:
version = version or core_manager.latest_version()
core = core_manager.get_core(version)
Expand All @@ -93,7 +95,7 @@ def _get_core_characters(version: str | None) -> list[CoreCharacter]:
)
app.include_router(generate_user_dict_router(user_dict, verify_mutability_allowed))
app.include_router(
generate_engine_info_router(core_manager, tts_engines, engine_manifest)
generate_engine_info_router(core_version_list, tts_engines, engine_manifest)
)
app.include_router(
generate_setting_router(
Expand Down
9 changes: 4 additions & 5 deletions voicevox_engine/app/routers/engine_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

from voicevox_engine import __version__
from voicevox_engine.core.core_adapter import DeviceSupport
from voicevox_engine.core.core_initializer import CoreManager
from voicevox_engine.engine_manifest import EngineManifest
from voicevox_engine.tts_pipeline.tts_engine import TTSEngineManager
from voicevox_engine.tts_pipeline.tts_engine import LATEST_VERSION, TTSEngineManager


class SupportedDevicesInfo(BaseModel):
Expand All @@ -33,7 +32,7 @@ def generate_from(cls, device_support: DeviceSupport) -> Self:


def generate_engine_info_router(
core_manager: CoreManager,
core_version_list: list[str],
tts_engine_manager: TTSEngineManager,
engine_manifest_data: EngineManifest,
) -> APIRouter:
Expand All @@ -48,14 +47,14 @@ async def version() -> str:
@router.get("/core_versions")
async def core_versions() -> list[str]:
"""利用可能なコアのバージョン一覧を取得します。"""
return core_manager.versions()
return core_version_list

@router.get("/supported_devices")
def supported_devices(
core_version: str | SkipJsonSchema[None] = None,
) -> SupportedDevicesInfo:
"""対応デバイスの一覧を取得します。"""
version = core_version or core_manager.latest_version()
version = core_version or LATEST_VERSION
supported_devices = tts_engine_manager.get_engine(version).supported_devices
if supported_devices is None:
raise HTTPException(status_code=422, detail="非対応の機能です。")
Expand Down

0 comments on commit f3e449f

Please sign in to comment.