From 8042b4baf1979de91dd8313d55229ce3c26d7f71 Mon Sep 17 00:00:00 2001 From: tarepan Date: Tue, 5 Dec 2023 04:23:34 +0900 Subject: [PATCH] =?UTF-8?q?=E8=BF=BD=E5=8A=A0:=20`SynthesisEngine`=20Core?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E9=83=BD=E5=BA=A6=E5=8F=96=E5=BE=97=20(#803)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../synthesis_engine/synthesis_engine.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/voicevox_engine/synthesis_engine/synthesis_engine.py b/voicevox_engine/synthesis_engine/synthesis_engine.py index 19b48e1f6..850c906a9 100644 --- a/voicevox_engine/synthesis_engine/synthesis_engine.py +++ b/voicevox_engine/synthesis_engine/synthesis_engine.py @@ -228,32 +228,32 @@ def calc_frame_phoneme(phonemes: List[OjtPhoneme], frame_per_phoneme: numpy.ndar class SynthesisEngine(SynthesisEngineBase): - def __init__( - self, - core: CoreWrapper, - ): - """ - speakers: coreから取得したspeakersに関するjsonデータの文字列 - """ + """音声合成器(core)の管理/実行/プロキシと音声合成フロー""" + + def __init__(self, core: CoreWrapper): super().__init__() self.core = core - self._speakers = self.core.metas() self.mutex = threading.Lock() - try: - self._supported_devices = self.core.supported_devices() - except OldCoreError: - self._supported_devices = None self.default_sampling_rate = 24000 @property def speakers(self) -> str: - return self._speakers + """話者情報(json文字列)""" + # Coreプロキシ + return self.core.metas() @property - def supported_devices(self) -> Optional[str]: - return self._supported_devices + def supported_devices(self) -> str | None: + """デバイスサポート情報""" + # Coreプロキシ + try: + supported_devices = self.core.supported_devices() + except OldCoreError: + supported_devices = None + return supported_devices def initialize_style_id_synthesis(self, style_id: int, skip_reinit: bool): + # Core管理 try: with self.mutex: # 以下の条件のいずれかを満たす場合, 初期化を実行する @@ -265,6 +265,7 @@ def initialize_style_id_synthesis(self, style_id: int, skip_reinit: bool): pass # コアが古い場合はどうしようもないので何もしない def is_initialized_style_id_synthesis(self, style_id: int) -> bool: + # Coreプロキシ try: return self.core.is_model_loaded(style_id) except OldCoreError: