From cac896bd46e001fa37dc3b586b534ae153275af3 Mon Sep 17 00:00:00 2001 From: tarepan Date: Mon, 3 Jun 2024 00:32:25 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86:=20`.load=5Fcombined=5Fmetas?= =?UTF-8?q?()`=20=E5=BC=95=E6=95=B0=E3=82=92=E5=A4=89=E6=9B=B4=20(#1352)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: `.load_combined_metas()` 引数を変更 --- voicevox_engine/app/routers/morphing.py | 4 ++-- voicevox_engine/app/routers/speaker.py | 6 ++++-- voicevox_engine/metas/MetasStore.py | 21 +++------------------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/voicevox_engine/app/routers/morphing.py b/voicevox_engine/app/routers/morphing.py index f3d587ef4..8e4274401 100644 --- a/voicevox_engine/app/routers/morphing.py +++ b/voicevox_engine/app/routers/morphing.py @@ -54,7 +54,7 @@ def morphable_targets( core = core_manager.get_core(core_version) try: - speakers = metas_store.load_combined_metas(core=core) + speakers = metas_store.load_combined_metas(core.speakers) morphable_targets = get_morphable_targets( speakers=speakers, base_style_ids=base_style_ids ) @@ -96,7 +96,7 @@ def _synthesis_morphing( core = core_manager.get_core(core_version) try: - speakers = metas_store.load_combined_metas(core=core) + speakers = metas_store.load_combined_metas(core.speakers) speaker_lookup = construct_lookup(speakers=speakers) is_permitted = is_synthesis_morphing_permitted( speaker_lookup, base_style_id, target_style_id diff --git a/voicevox_engine/app/routers/speaker.py b/voicevox_engine/app/routers/speaker.py index 01b7d7e42..344b5aa49 100644 --- a/voicevox_engine/app/routers/speaker.py +++ b/voicevox_engine/app/routers/speaker.py @@ -27,7 +27,8 @@ def generate_speaker_router( @router.get("/speakers") def speakers(core_version: str | None = None) -> list[Speaker]: """話者情報の一覧を取得します。""" - speakers = metas_store.load_combined_metas(core_manager.get_core(core_version)) + core = core_manager.get_core(core_version) + speakers = metas_store.load_combined_metas(core.speakers) return filter_speakers_and_styles(speakers, "speaker") @router.get("/speaker_info") @@ -136,7 +137,8 @@ def _speaker_info( @router.get("/singers") def singers(core_version: str | None = None) -> list[Speaker]: """歌手情報の一覧を取得します""" - singers = metas_store.load_combined_metas(core_manager.get_core(core_version)) + core = core_manager.get_core(core_version) + singers = metas_store.load_combined_metas(core.speakers) return filter_speakers_and_styles(singers, "singer") @router.get("/singer_info") diff --git a/voicevox_engine/metas/MetasStore.py b/voicevox_engine/metas/MetasStore.py index da8860334..db9b05722 100644 --- a/voicevox_engine/metas/MetasStore.py +++ b/voicevox_engine/metas/MetasStore.py @@ -5,7 +5,7 @@ from pydantic import BaseModel, Field -from voicevox_engine.core.core_adapter import CoreAdapter, CoreSpeakerStyle +from voicevox_engine.core.core_adapter import CoreSpeaker, CoreSpeakerStyle from voicevox_engine.metas.Metas import ( Speaker, SpeakerStyle, @@ -53,23 +53,8 @@ def __init__(self, engine_speakers_path: Path) -> None: for folder in engine_speakers_path.iterdir() } - # FIXME: engineではなくlist[CoreSpeaker]を渡す形にすることで - # TTSEngineによる循環importを修正する - def load_combined_metas(self, core: CoreAdapter) -> list[Speaker]: - """ - コアに含まれる話者メタ情報とエンジンに含まれる話者メタ情報を統合 - Parameters - ---------- - core : CoreAdapter - 話者メタ情報をもったコア - Returns - ------- - ret : list[Speaker] - エンジンとコアに含まれる話者メタ情報 - """ - # コアに含まれる話者メタ情報の収集 - core_metas = core.speakers - # エンジンに含まれる話者メタ情報との統合 + def load_combined_metas(self, core_metas: list[CoreSpeaker]) -> list[Speaker]: + """コアとエンジンのメタ情報を統合する。""" return [ Speaker( supported_features=self._loaded_metas[