Skip to content

Commit

Permalink
整理: talk/sing キャラクターの取得をメソッドへ移動 (#1418)
Browse files Browse the repository at this point in the history
refactor: talk/sing キャラクターの取得をメソッドへ移動
  • Loading branch information
tarepan authored Jun 22, 2024
1 parent 6720ac2 commit 94acb66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions voicevox_engine/app/routers/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions voicevox_engine/metas/MetasStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 94acb66

Please sign in to comment.