diff --git a/build_util/make_docs.py b/build_util/make_docs.py index f6a15ae25..6d5a1a8a5 100644 --- a/build_util/make_docs.py +++ b/build_util/make_docs.py @@ -2,11 +2,13 @@ from pathlib import Path from voicevox_engine.app.application import generate_app +from voicevox_engine.core.core_adapter import CoreAdapter +from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.dev.core.mock import MockCoreWrapper from voicevox_engine.dev.tts_engine.mock import MockTTSEngine from voicevox_engine.preset.PresetManager import PresetManager from voicevox_engine.setting.SettingLoader import USER_SETTING_PATH, SettingHandler -from voicevox_engine.tts_pipeline.tts_engine import CoreAdapter, TTSEngineManager +from voicevox_engine.tts_pipeline.tts_engine import TTSEngineManager from voicevox_engine.user_dict.user_dict import UserDictionary from voicevox_engine.utility.path_utility import engine_root @@ -35,13 +37,14 @@ def generate_api_docs_html(schema: str) -> str: if __name__ == "__main__": - mock_core = MockCoreWrapper() + core_manager = CoreManager() + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "mock") tts_engines = TTSEngineManager() tts_engines.register_engine(MockTTSEngine(), "mock") # FastAPI の機能を用いて OpenAPI schema を生成する app = generate_app( tts_engines=tts_engines, - cores={"mock": CoreAdapter(mock_core)}, + core_manager=core_manager, latest_core_version="mock", setting_loader=SettingHandler(USER_SETTING_PATH), preset_manager=PresetManager( # FIXME: impl MockPresetManager diff --git a/run.py b/run.py index ac27f1300..170471a83 100644 --- a/run.py +++ b/run.py @@ -256,7 +256,7 @@ def main() -> None: cpu_num_threads: int | None = args.cpu_num_threads load_all_models: bool = args.load_all_models - cores = initialize_cores( + core_manager = initialize_cores( use_gpu=use_gpu, voicelib_dirs=voicelib_dirs, voicevox_dir=voicevox_dir, @@ -265,7 +265,7 @@ def main() -> None: enable_mock=enable_mock, load_all_models=load_all_models, ) - tts_engines = make_tts_engines_from_cores(cores) + tts_engines = make_tts_engines_from_cores(core_manager) assert len(tts_engines.versions()) != 0, "音声合成エンジンがありません。" latest_core_version = tts_engines.latest_version() @@ -325,7 +325,7 @@ def main() -> None: # ASGI に準拠した VOICEVOX ENGINE アプリケーションを生成する app = generate_app( tts_engines, - cores, + core_manager, latest_core_version, setting_loader, preset_manager, diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index 2ec63da25..d91022825 100644 --- a/test/e2e/conftest.py +++ b/test/e2e/conftest.py @@ -16,8 +16,8 @@ @pytest.fixture() def app_params(tmp_path: Path) -> dict[str, Any]: - cores = initialize_cores(use_gpu=False, enable_mock=True) - tts_engines = make_tts_engines_from_cores(cores) + core_manager = initialize_cores(use_gpu=False, enable_mock=True) + tts_engines = make_tts_engines_from_cores(core_manager) latest_core_version = tts_engines.latest_version() setting_loader = SettingHandler(Path("./not_exist.yaml")) @@ -30,7 +30,7 @@ def app_params(tmp_path: Path) -> dict[str, Any]: return { "tts_engines": tts_engines, - "cores": cores, + "core_manager": core_manager, "latest_core_version": latest_core_version, "setting_loader": setting_loader, "preset_manager": preset_manager, diff --git a/test/test_core_initializer.py b/test/test_core_initializer.py index 972e3ff5b..c1bc1920e 100644 --- a/test/test_core_initializer.py +++ b/test/test_core_initializer.py @@ -1,7 +1,148 @@ +""" `core_initializer.py` のテスト""" + from unittest import TestCase from unittest.mock import patch -from voicevox_engine.core.core_initializer import get_half_logical_cores +import pytest +from fastapi import HTTPException + +from voicevox_engine.core.core_adapter import CoreAdapter +from voicevox_engine.core.core_initializer import CoreManager, get_half_logical_cores +from voicevox_engine.dev.core.mock import MockCoreWrapper + + +def test_cores_register_core() -> None: + """CoreManager.register_core() でコアを登録できる。""" + # Inputs + core_manager = CoreManager() + + # Test + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.1") + + +def test_cores_versions() -> None: + """CoreManager.versions() でバージョン一覧を取得できる。""" + # Inputs + core_manager = CoreManager() + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.1") + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.2") + # Expects + true_versions = ["0.0.1", "0.0.2"] + # Outputs + versions = core_manager.versions() + + # Test + assert true_versions == versions + + +def test_cores_latest_version() -> None: + """CoreManager.latest_version() で最新バージョンを取得できる。""" + # Inputs + core_manager = CoreManager() + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.1") + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.2") + # Expects + true_latest_version = "0.0.2" + # Outputs + latest_version = core_manager.latest_version() + + # Test + assert true_latest_version == latest_version + + +def test_cores_get_core_specified() -> None: + """CoreManager.get_core() で登録済みコアをバージョン指定して取得できる。""" + # Inputs + core_manager = CoreManager() + core1 = CoreAdapter(MockCoreWrapper()) + core2 = CoreAdapter(MockCoreWrapper()) + core_manager.register_core(core1, "0.0.1") + core_manager.register_core(core2, "0.0.2") + # Expects + true_acquired_core = core2 + # Outputs + acquired_core = core_manager.get_core("0.0.2") + + # Test + assert true_acquired_core == acquired_core + + +def test_cores_get_core_latest() -> None: + """CoreManager.get_core() で最新版コアをバージョン未指定で取得できる。""" + # Inputs + core_manager = CoreManager() + core1 = CoreAdapter(MockCoreWrapper()) + core2 = CoreAdapter(MockCoreWrapper()) + core_manager.register_core(core1, "0.0.1") + core_manager.register_core(core2, "0.0.2") + # Expects + true_acquired_core = core2 + # Outputs + acquired_core = core_manager.get_core() + + # Test + assert true_acquired_core == acquired_core + + +def test_cores_get_core_missing() -> None: + """CoreManager.get_core() で存在しないコアを取得しようとするとエラーになる。""" + # Inputs + core_manager = CoreManager() + core1 = CoreAdapter(MockCoreWrapper()) + core2 = CoreAdapter(MockCoreWrapper()) + core_manager.register_core(core1, "0.0.1") + core_manager.register_core(core2, "0.0.2") + + # Test + with pytest.raises(HTTPException) as _: + core_manager.get_core("0.0.3") + + +def test_cores_has_core_true() -> None: + """CoreManager.has_core() でコアが登録されていることを確認できる。""" + # Inputs + core_manager = CoreManager() + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.1") + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.2") + # Expects + true_has = True + # Outputs + has = core_manager.has_core("0.0.1") + + # Test + assert true_has == has + + +def test_cores_has_core_false() -> None: + """CoreManager.has_core() でコアが登録されていないことを確認できる。""" + # Inputs + core_manager = CoreManager() + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.1") + core_manager.register_core(CoreAdapter(MockCoreWrapper()), "0.0.2") + # Expects + true_has = False + # Outputs + has = core_manager.has_core("0.0.3") + + # Test + assert true_has == has + + +def test_cores_items() -> None: + """CoreManager.items() でコアとバージョンのリストを取得できる。""" + # Inputs + core_manager = CoreManager() + core1 = CoreAdapter(MockCoreWrapper()) + core2 = CoreAdapter(MockCoreWrapper()) + core_manager.register_core(core1, "0.0.1") + core_manager.register_core(core2, "0.0.2") + # Expects + true_items = [("0.0.1", core1), ("0.0.2", core2)] + # Outputs + items = core_manager.items() + + # Test + assert true_items == items class TestHalfLogicalCores(TestCase): diff --git a/voicevox_engine/app/application.py b/voicevox_engine/app/application.py index ad25812f5..c22909a54 100644 --- a/voicevox_engine/app/application.py +++ b/voicevox_engine/app/application.py @@ -1,6 +1,6 @@ from pathlib import Path -from fastapi import FastAPI, HTTPException +from fastapi import FastAPI from voicevox_engine import __version__ from voicevox_engine.app.dependencies import deprecated_mutable_api @@ -16,7 +16,7 @@ from voicevox_engine.app.routers.tts_pipeline import generate_tts_pipeline_router from voicevox_engine.app.routers.user_dict import generate_user_dict_router from voicevox_engine.cancellable_engine import CancellableEngine -from voicevox_engine.core.core_adapter import CoreAdapter +from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.engine_manifest.EngineManifestLoader import load_manifest from voicevox_engine.library_manager import LibraryManager from voicevox_engine.metas.MetasStore import MetasStore @@ -30,7 +30,7 @@ def generate_app( tts_engines: TTSEngineManager, - cores: dict[str, CoreAdapter], + core_manager: CoreManager, latest_core_version: str, setting_loader: SettingHandler, preset_manager: PresetManager, @@ -69,30 +69,20 @@ def generate_app( metas_store = MetasStore(root_dir / "speaker_info") - def get_core(core_version: str | None) -> CoreAdapter: - """指定したバージョンのコアを取得する""" - if core_version is None: - return cores[latest_core_version] - if core_version in cores: - return cores[core_version] - raise HTTPException(status_code=422, detail="不明なバージョンです") - app.include_router( generate_tts_pipeline_router( - tts_engines, get_core, preset_manager, cancellable_engine + tts_engines, core_manager, preset_manager, cancellable_engine ) ) - app.include_router(generate_morphing_router(tts_engines, get_core, metas_store)) + app.include_router(generate_morphing_router(tts_engines, core_manager, metas_store)) app.include_router(generate_preset_router(preset_manager)) - app.include_router(generate_speaker_router(get_core, metas_store, root_dir)) + app.include_router(generate_speaker_router(core_manager, metas_store, root_dir)) if engine_manifest_data.supported_features.manage_library: app.include_router( generate_library_router(engine_manifest_data, library_manager) ) app.include_router(generate_user_dict_router(user_dict)) - app.include_router( - generate_engine_info_router(get_core, cores, engine_manifest_data) - ) + app.include_router(generate_engine_info_router(core_manager, engine_manifest_data)) app.include_router(generate_setting_router(setting_loader, engine_manifest_data)) app.include_router(generate_portal_page_router(engine_manifest_data)) diff --git a/voicevox_engine/app/routers/engine_info.py b/voicevox_engine/app/routers/engine_info.py index 6ad6ce768..d2894f706 100644 --- a/voicevox_engine/app/routers/engine_info.py +++ b/voicevox_engine/app/routers/engine_info.py @@ -1,20 +1,17 @@ """エンジンの情報機能を提供する API Router""" import json -from typing import Callable from fastapi import APIRouter, HTTPException, Response from voicevox_engine import __version__ -from voicevox_engine.core.core_adapter import CoreAdapter +from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.engine_manifest.EngineManifest import EngineManifest from voicevox_engine.model import SupportedDevicesInfo def generate_engine_info_router( - get_core: Callable[[str | None], CoreAdapter], - cores: dict[str, CoreAdapter], - engine_manifest_data: EngineManifest, + core_manager: CoreManager, engine_manifest_data: EngineManifest ) -> APIRouter: """エンジン情報 API Router を生成する""" router = APIRouter() @@ -28,7 +25,7 @@ async def version() -> str: async def core_versions() -> Response: """利用可能なコアのバージョン一覧を取得します。""" return Response( - content=json.dumps(list(cores.keys())), + content=json.dumps(core_manager.versions()), media_type="application/json", ) @@ -37,7 +34,7 @@ async def core_versions() -> Response: ) def supported_devices(core_version: str | None = None) -> Response: """対応デバイスの一覧を取得します。""" - supported_devices = get_core(core_version).supported_devices + supported_devices = core_manager.get_core(core_version).supported_devices if supported_devices is None: raise HTTPException(status_code=422, detail="非対応の機能です。") return Response( diff --git a/voicevox_engine/app/routers/morphing.py b/voicevox_engine/app/routers/morphing.py index 0d015d094..f4fa66ce9 100644 --- a/voicevox_engine/app/routers/morphing.py +++ b/voicevox_engine/app/routers/morphing.py @@ -2,14 +2,14 @@ from functools import lru_cache from tempfile import NamedTemporaryFile -from typing import Annotated, Callable +from typing import Annotated import soundfile from fastapi import APIRouter, HTTPException, Query from starlette.background import BackgroundTask from starlette.responses import FileResponse -from voicevox_engine.core.core_adapter import CoreAdapter +from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.metas.Metas import StyleId from voicevox_engine.metas.MetasStore import MetasStore, construct_lookup from voicevox_engine.model import AudioQuery, MorphableTargetInfo, StyleIdNotFoundError @@ -32,7 +32,7 @@ def generate_morphing_router( tts_engines: TTSEngineManager, - get_core: Callable[[str | None], CoreAdapter], + core_manager: CoreManager, metas_store: MetasStore, ) -> APIRouter: """モーフィング API Router を生成する""" @@ -52,7 +52,7 @@ def morphable_targets( プロパティが存在しない場合は、モーフィングが許可されているとみなします。 返り値のスタイルIDはstring型なので注意。 """ - core = get_core(core_version) + core = core_manager.get_core(core_version) try: speakers = metas_store.load_combined_metas(core=core) @@ -95,7 +95,7 @@ def _synthesis_morphing( モーフィングの割合は`morph_rate`で指定でき、0.0でベースのスタイル、1.0でターゲットのスタイルに近づきます。 """ engine = tts_engines.get_engine(core_version) - core = get_core(core_version) + core = core_manager.get_core(core_version) try: speakers = metas_store.load_combined_metas(core=core) diff --git a/voicevox_engine/app/routers/speaker.py b/voicevox_engine/app/routers/speaker.py index 78a4ff9bd..834db34a9 100644 --- a/voicevox_engine/app/routers/speaker.py +++ b/voicevox_engine/app/routers/speaker.py @@ -3,12 +3,12 @@ import base64 import json from pathlib import Path -from typing import Annotated, Callable, Literal +from typing import Annotated, Literal from fastapi import APIRouter, HTTPException, Query from pydantic import parse_obj_as -from voicevox_engine.core.core_adapter import CoreAdapter +from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.metas.Metas import StyleId from voicevox_engine.metas.MetasStore import MetasStore, filter_speakers_and_styles from voicevox_engine.model import Speaker, SpeakerInfo @@ -19,7 +19,7 @@ def b64encode_str(s: bytes) -> str: def generate_speaker_router( - get_core: Callable[[str | None], CoreAdapter], + core_manager: CoreManager, metas_store: MetasStore, root_dir: Path, ) -> APIRouter: @@ -30,7 +30,7 @@ def generate_speaker_router( def speakers( core_version: str | None = None, ) -> list[Speaker]: - speakers = metas_store.load_combined_metas(get_core(core_version)) + speakers = metas_store.load_combined_metas(core_manager.get_core(core_version)) return filter_speakers_and_styles(speakers, "speaker") @router.get("/speaker_info", tags=["その他"]) @@ -79,7 +79,7 @@ def _speaker_info( # 該当話者の検索 speakers = parse_obj_as( - list[Speaker], json.loads(get_core(core_version).speakers) + list[Speaker], json.loads(core_manager.get_core(core_version).speakers) ) speakers = filter_speakers_and_styles(speakers, speaker_or_singer) for i in range(len(speakers)): @@ -147,7 +147,7 @@ def _speaker_info( def singers( core_version: str | None = None, ) -> list[Speaker]: - singers = metas_store.load_combined_metas(get_core(core_version)) + singers = metas_store.load_combined_metas(core_manager.get_core(core_version)) return filter_speakers_and_styles(singers, "singer") @router.get("/singer_info", tags=["その他"]) @@ -180,7 +180,7 @@ def initialize_speaker( 指定されたスタイルを初期化します。 実行しなくても他のAPIは使用できますが、初回実行時に時間がかかることがあります。 """ - core = get_core(core_version) + core = core_manager.get_core(core_version) core.initialize_style_id_synthesis(style_id, skip_reinit=skip_reinit) @router.get("/is_initialized_speaker", tags=["その他"]) @@ -191,7 +191,7 @@ def is_initialized_speaker( """ 指定されたスタイルが初期化されているかどうかを返します。 """ - core = get_core(core_version) + core = core_manager.get_core(core_version) return core.is_initialized_style_id_synthesis(style_id) return router diff --git a/voicevox_engine/app/routers/tts_pipeline.py b/voicevox_engine/app/routers/tts_pipeline.py index d4afa5c3c..cd5855c2e 100644 --- a/voicevox_engine/app/routers/tts_pipeline.py +++ b/voicevox_engine/app/routers/tts_pipeline.py @@ -2,7 +2,7 @@ import zipfile from tempfile import NamedTemporaryFile, TemporaryFile -from typing import Annotated, Callable +from typing import Annotated import soundfile from fastapi import APIRouter, HTTPException, Query, Request @@ -10,7 +10,7 @@ from starlette.responses import FileResponse from voicevox_engine.cancellable_engine import CancellableEngine -from voicevox_engine.core.core_adapter import CoreAdapter +from voicevox_engine.core.core_initializer import CoreManager from voicevox_engine.metas.Metas import StyleId from voicevox_engine.model import ( AccentPhrase, @@ -33,7 +33,7 @@ def generate_tts_pipeline_router( tts_engines: TTSEngineManager, - get_core: Callable[[str | None], CoreAdapter], + core_manager: CoreManager, preset_manager: PresetManager, cancellable_engine: CancellableEngine | None, ) -> APIRouter: @@ -54,7 +54,7 @@ def audio_query( 音声合成用のクエリの初期値を得ます。ここで得られたクエリはそのまま音声合成に利用できます。各値の意味は`Schemas`を参照してください。 """ engine = tts_engines.get_engine(core_version) - core = get_core(core_version) + core = core_manager.get_core(core_version) accent_phrases = engine.create_accent_phrases(text, style_id) return AudioQuery( accent_phrases=accent_phrases, @@ -83,7 +83,7 @@ def audio_query_from_preset( 音声合成用のクエリの初期値を得ます。ここで得られたクエリはそのまま音声合成に利用できます。各値の意味は`Schemas`を参照してください。 """ engine = tts_engines.get_engine(core_version) - core = get_core(core_version) + core = core_manager.get_core(core_version) try: presets = preset_manager.load_presets() except PresetInputError as err: @@ -328,7 +328,7 @@ def sing_frame_audio_query( 歌唱音声合成用のクエリの初期値を得ます。ここで得られたクエリはそのまま歌唱音声合成に利用できます。各値の意味は`Schemas`を参照してください。 """ engine = tts_engines.get_engine(core_version) - core = get_core(core_version) + core = core_manager.get_core(core_version) phonemes, f0, volume = engine.create_sing_phoneme_and_f0_and_volume( score, style_id ) diff --git a/voicevox_engine/cancellable_engine.py b/voicevox_engine/cancellable_engine.py index 74f32c80f..cef3ec1a3 100644 --- a/voicevox_engine/cancellable_engine.py +++ b/voicevox_engine/cancellable_engine.py @@ -227,7 +227,7 @@ def start_synthesis_subprocess( メインプロセスと通信するためのPipe """ - cores = initialize_cores( + core_manager = initialize_cores( use_gpu=use_gpu, voicelib_dirs=voicelib_dirs, voicevox_dir=voicevox_dir, @@ -235,7 +235,7 @@ def start_synthesis_subprocess( cpu_num_threads=cpu_num_threads, enable_mock=enable_mock, ) - tts_engines = make_tts_engines_from_cores(cores) + tts_engines = make_tts_engines_from_cores(core_manager) assert len(tts_engines.versions()) != 0, "音声合成エンジンがありません。" while True: diff --git a/voicevox_engine/core/core_initializer.py b/voicevox_engine/core/core_initializer.py index 461709f7d..14b3eef1d 100644 --- a/voicevox_engine/core/core_initializer.py +++ b/voicevox_engine/core/core_initializer.py @@ -3,8 +3,11 @@ import sys from pathlib import Path -from ..tts_pipeline.tts_engine import CoreAdapter +from fastapi import HTTPException + +from ..utility.core_version_utility import get_latest_version from ..utility.path_utility import engine_root, get_save_dir +from .core_adapter import CoreAdapter from .core_wrapper import CoreWrapper, load_runtime_lib MOCK_VER = "0.0.0" @@ -17,6 +20,43 @@ def get_half_logical_cores() -> int: return logical_cores // 2 +class CoreManager: + """コアの集まりを一括管理するマネージャー""" + + def __init__(self) -> None: + self._cores: dict[str, CoreAdapter] = {} + + def versions(self) -> list[str]: + """登録されたコアのバージョン一覧を取得する。""" + return list(self._cores.keys()) + + def latest_version(self) -> str: + """登録された最新版コアのバージョンを取得する。""" + return get_latest_version(self.versions()) + + def register_core(self, core: CoreAdapter, version: str) -> None: + """コアを登録する。""" + self._cores[version] = core + + def get_core(self, version: str | None = None) -> CoreAdapter: + """指定バージョンのコアを取得する。指定が無い場合、最新バージョンを返す。""" + if version is None: + return self._cores[self.latest_version()] + elif version in self._cores: + return self._cores[version] + + # FIXME: ドメインがずれているのでこのエラーは routers へ持っていく + raise HTTPException(status_code=422, detail="不明なバージョンです") + + def has_core(self, version: str) -> bool: + """指定バージョンのコアが登録されているか否かを返す。""" + return version in self._cores + + def items(self) -> list[tuple[str, CoreAdapter]]: + """登録されたコアとそのバージョンのリストを取得する。""" + return list(self._cores.items()) + + def initialize_cores( use_gpu: bool, voicelib_dirs: list[Path] | None = None, @@ -25,7 +65,7 @@ def initialize_cores( cpu_num_threads: int | None = None, enable_mock: bool = True, load_all_models: bool = False, -) -> dict[str, CoreAdapter]: +) -> CoreManager: """ 音声ライブラリをロードしてコアを生成 @@ -66,8 +106,8 @@ def initialize_cores( # ランタイムをロードする load_runtime_lib(runtime_dirs) - # コアをロードし `cores` へ登録する - cores: dict[str, CoreAdapter] = {} + # コアをロードし `core_manager` へ登録する + core_manager = CoreManager() # 引数による指定を反映し、無ければ `root_dir` とする voicelib_dirs = voicelib_dirs or [] @@ -79,7 +119,7 @@ def initialize_cores( def load_core_library(core_dir: Path, suppress_error: bool = False) -> None: """ - 指定されたコアをロードし `cores` へ登録する。 + 指定されたコアをロードし `core_manager` へ登録する。 Parameters ---------- core_dir : Path @@ -93,15 +133,15 @@ def load_core_library(core_dir: Path, suppress_error: bool = False) -> None: core = CoreWrapper(use_gpu, core_dir, cpu_num_threads, load_all_models) # コアを登録する metas = json.loads(core.metas()) - core_version = metas[0]["version"] + core_version: str = metas[0]["version"] print(f"Info: Loading core {core_version}.") - if core_version in cores: + if core_manager.has_core(core_version): print( "Warning: Core loading is skipped because of version duplication.", file=sys.stderr, ) else: - cores[core_version] = CoreAdapter(core) + core_manager.register_core(CoreAdapter(core), core_version) except Exception: # コアでなかった場合のエラーを抑制する if not suppress_error: @@ -129,9 +169,9 @@ def load_core_library(core_dir: Path, suppress_error: bool = False) -> None: # モック追加 from ..dev.core.mock import MockCoreWrapper - if MOCK_VER not in cores: + if not core_manager.has_core(MOCK_VER): print("Info: Loading mock.") core = MockCoreWrapper() - cores[MOCK_VER] = CoreAdapter(core) + core_manager.register_core(CoreAdapter(core), MOCK_VER) - return cores + return core_manager diff --git a/voicevox_engine/tts_pipeline/tts_engine.py b/voicevox_engine/tts_pipeline/tts_engine.py index d2c1f167d..cc35cf5ae 100644 --- a/voicevox_engine/tts_pipeline/tts_engine.py +++ b/voicevox_engine/tts_pipeline/tts_engine.py @@ -7,6 +7,7 @@ from soxr import resample from ..core.core_adapter import CoreAdapter +from ..core.core_initializer import CoreManager from ..core.core_wrapper import CoreWrapper from ..metas.Metas import StyleId from ..model import ( @@ -715,12 +716,12 @@ def has_engine(self, version: str) -> bool: return version in self._engines -def make_tts_engines_from_cores(cores: dict[str, CoreAdapter]) -> TTSEngineManager: +def make_tts_engines_from_cores(core_manager: CoreManager) -> TTSEngineManager: """コア一覧からTTSエンジン一覧を生成する""" # FIXME: `MOCK_VER` を循環 import 無しに `initialize_cores()` 関連モジュールから import する MOCK_VER = "0.0.0" tts_engines = TTSEngineManager() - for ver, core in cores.items(): + for ver, core in core_manager.items(): if ver == MOCK_VER: from ..dev.tts_engine.mock import MockTTSEngine