diff --git a/test/test_synthesis_engine.py b/test/test_synthesis_engine.py index 24e20da5f..ed9e891d5 100644 --- a/test/test_synthesis_engine.py +++ b/test/test_synthesis_engine.py @@ -109,6 +109,7 @@ def decode_mock( class MockCore: + default_sampling_rate = 24000 yukarin_s_forward = Mock(side_effect=yukarin_s_mock) yukarin_sa_forward = Mock(side_effect=yukarin_sa_mock) decode_forward = Mock(side_effect=decode_mock) diff --git a/test/test_synthesis_engine_base.py b/test/test_synthesis_engine_base.py index 8202891b7..c49dcbe01 100644 --- a/test/test_synthesis_engine_base.py +++ b/test/test_synthesis_engine_base.py @@ -169,6 +169,7 @@ def create_mock_query(accent_phrases): class MockCore: + default_sampling_rate = 24000 yukarin_s_forward = Mock(side_effect=yukarin_s_mock) yukarin_sa_forward = Mock(side_effect=yukarin_sa_mock) decode_forward = Mock(side_effect=decode_mock) diff --git a/voicevox_engine/dev/synthesis_engine/mock.py b/voicevox_engine/dev/synthesis_engine/mock.py index 9f49f5953..1b6c4abeb 100644 --- a/voicevox_engine/dev/synthesis_engine/mock.py +++ b/voicevox_engine/dev/synthesis_engine/mock.py @@ -27,7 +27,10 @@ def __init__( self._speakers = speakers self._supported_devices = supported_devices - self.default_sampling_rate = 24000 + + @property + def default_sampling_rate(self) -> int: + return 24000 @property def speakers(self) -> str: diff --git a/voicevox_engine/synthesis_engine/core_wrapper.py b/voicevox_engine/synthesis_engine/core_wrapper.py index 720c470f4..047552bc5 100644 --- a/voicevox_engine/synthesis_engine/core_wrapper.py +++ b/voicevox_engine/synthesis_engine/core_wrapper.py @@ -357,6 +357,8 @@ def __init__( load_all_models: bool = False, ) -> None: + self.default_sampling_rate = 24000 + self.core = load_core(core_dir, use_gpu) self.core.initialize.restype = c_bool diff --git a/voicevox_engine/synthesis_engine/synthesis_engine.py b/voicevox_engine/synthesis_engine/synthesis_engine.py index 850c906a9..760243df7 100644 --- a/voicevox_engine/synthesis_engine/synthesis_engine.py +++ b/voicevox_engine/synthesis_engine/synthesis_engine.py @@ -234,7 +234,10 @@ def __init__(self, core: CoreWrapper): super().__init__() self.core = core self.mutex = threading.Lock() - self.default_sampling_rate = 24000 + + @property + def default_sampling_rate(self) -> int: + return self.core.default_sampling_rate @property def speakers(self) -> str: diff --git a/voicevox_engine/synthesis_engine/synthesis_engine_base.py b/voicevox_engine/synthesis_engine/synthesis_engine_base.py index f6f798a7c..fde453574 100644 --- a/voicevox_engine/synthesis_engine/synthesis_engine_base.py +++ b/voicevox_engine/synthesis_engine/synthesis_engine_base.py @@ -80,6 +80,11 @@ def full_context_label_moras_to_moras( class SynthesisEngineBase(metaclass=ABCMeta): + @property + @abstractmethod + def default_sampling_rate(self) -> int: + raise NotImplementedError + # FIXME: jsonではなくModelを返すようにする @property @abstractmethod