baicai-1145 800f01790e Refactor EngineApiFacade and EngineApiDelegates for improved method naming and structure
Rename several methods in EngineApiFacade to follow a consistent private naming convention, enhancing code clarity. Update EngineApiDelegates to remove redundant method definitions, streamlining the interface. Introduce EnginePublicInterface to encapsulate public API methods, improving organization and maintainability of the TTS system. Additionally, update the EngineCompositionBuilder to use the new scheduler worker state retrieval method.
2026-03-11 17:58:20 +08:00

47 lines
1.8 KiB
Python

from __future__ import annotations
import os
from typing import Sequence
from GPT_SoVITS.TTS_infer_pack.TTS import TTS
from GPT_SoVITS.TTS_infer_pack.unified_engine_builder import EngineCompositionBuilder
from GPT_SoVITS.TTS_infer_pack.unified_engine_components import RuntimeControlCallbacks
from GPT_SoVITS.TTS_infer_pack.unified_engine_delegates import EngineApiDelegates, EngineBridgeDelegates, EngineRuntimeDelegates
from GPT_SoVITS.TTS_infer_pack.unified_engine_public import EngineCompatInterface, EnginePublicInterface
class UnifiedTTSEngine(EnginePublicInterface, EngineCompatInterface, EngineBridgeDelegates, EngineApiDelegates, EngineRuntimeDelegates):
@staticmethod
def _env_flag(name: str, default: bool) -> bool:
value = os.environ.get(name)
if value is None:
return bool(default)
return str(value).strip().lower() not in {"0", "false", "no", "off", ""}
@staticmethod
def _env_int(name: str, default: int) -> int:
value = os.environ.get(name)
if value in [None, ""]:
return int(default)
return int(value)
@staticmethod
def _env_float(name: str, default: float) -> float:
value = os.environ.get(name)
if value in [None, ""]:
return float(default)
return float(value)
def __init__(
self,
tts: TTS,
cut_method_names: Sequence[str],
control_callbacks: RuntimeControlCallbacks | None = None,
max_steps: int = 1500,
micro_batch_wait_ms: int = 5,
) -> None:
self.tts = tts
self.cut_method_names = set(cut_method_names)
self.control_callbacks = control_callbacks or RuntimeControlCallbacks()
EngineCompositionBuilder(self).build(max_steps=max_steps, micro_batch_wait_ms=micro_batch_wait_ms)