Skip to content

Commit

Permalink
整理: .load_combined_metas() 引数を変更 (#1352)
Browse files Browse the repository at this point in the history
refactor: `.load_combined_metas()` 引数を変更
  • Loading branch information
tarepan authored Jun 2, 2024
1 parent f34da2f commit cac896b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions voicevox_engine/app/routers/morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions voicevox_engine/app/routers/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
21 changes: 3 additions & 18 deletions voicevox_engine/metas/MetasStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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[
Expand Down

0 comments on commit cac896b

Please sign in to comment.