From 94acb66681a64740d08d24080396be3ad9c4fc19 Mon Sep 17 00:00:00 2001 From: tarepan Date: Sun, 23 Jun 2024 07:14:46 +0900 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86:=20talk/sing=20=E3=82=AD?= =?UTF-8?q?=E3=83=A3=E3=83=A9=E3=82=AF=E3=82=BF=E3=83=BC=E3=81=AE=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=82=92=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=B8?= =?UTF-8?q?=E7=A7=BB=E5=8B=95=20(#1418)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: talk/sing キャラクターの取得をメソッドへ移動 --- voicevox_engine/app/routers/character.py | 6 ++---- voicevox_engine/metas/MetasStore.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/voicevox_engine/app/routers/character.py b/voicevox_engine/app/routers/character.py index a075b56ea..722f53843 100644 --- a/voicevox_engine/app/routers/character.py +++ b/voicevox_engine/app/routers/character.py @@ -29,8 +29,7 @@ def speakers(core_version: str | SkipJsonSchema[None] = None) -> list[Speaker]: """話者情報の一覧を取得します。""" version = core_version or core_manager.latest_version() core = core_manager.get_core(version) - characters = metas_store.load_combined_metas(core.characters) - return filter_characters_and_styles(characters, "speaker") + return metas_store.talk_characters(core.characters) @router.get("/speaker_info") def speaker_info( @@ -143,8 +142,7 @@ def singers(core_version: str | SkipJsonSchema[None] = None) -> list[Speaker]: """歌手情報の一覧を取得します""" version = core_version or core_manager.latest_version() core = core_manager.get_core(version) - characters = metas_store.load_combined_metas(core.characters) - return filter_characters_and_styles(characters, "singer") + return metas_store.sing_characters(core.characters) @router.get("/singer_info") def singer_info( diff --git a/voicevox_engine/metas/MetasStore.py b/voicevox_engine/metas/MetasStore.py index 8c758b984..9d50644c8 100644 --- a/voicevox_engine/metas/MetasStore.py +++ b/voicevox_engine/metas/MetasStore.py @@ -110,6 +110,16 @@ def load_combined_metas( ) return characters + def talk_characters(self, core_characters: list[CoreCharacter]) -> list[Speaker]: + """話せるキャラクターの情報の一覧を取得する。""" + characters = self.load_combined_metas(core_characters) + return filter_characters_and_styles(characters, "speaker") + + def sing_characters(self, core_characters: list[CoreCharacter]) -> list[Speaker]: + """歌えるキャラクターの情報の一覧を取得する。""" + characters = self.load_combined_metas(core_characters) + return filter_characters_and_styles(characters, "singer") + def filter_characters_and_styles( characters: list[Character],