diff --git a/voicevox_engine/synthesis_engine/core_wrapper.py b/voicevox_engine/synthesis_engine/core_wrapper.py index 14afa427f..dcb2da101 100644 --- a/voicevox_engine/synthesis_engine/core_wrapper.py +++ b/voicevox_engine/synthesis_engine/core_wrapper.py @@ -378,6 +378,64 @@ def load_core(core_dir: Path, use_gpu: bool) -> CDLL: raise RuntimeError(f"このコンピュータのアーキテクチャ {platform.machine()} で利用可能なコアがありません") +def _type_yukarin_s_forward(core_cdll: CDLL) -> None: + """ + コアDLL `yukarin_s_forward` 関数の型付け + Parameters + ---------- + core_cdll : CDLL + コアDLL + """ + core_cdll.yukarin_s_forward.argtypes = ( + c_int, + POINTER(c_long), + POINTER(c_long), + POINTER(c_float), + ) + core_cdll.yukarin_s_forward.restype = c_bool + + +def _type_yukarin_sa_forward(core_cdll: CDLL) -> None: + """ + コアDLL `yukarin_sa_forward` 関数の型付け + Parameters + ---------- + core_cdll : CDLL + コアDLL + """ + core_cdll.yukarin_sa_forward.argtypes = ( + c_int, + POINTER(c_long), + POINTER(c_long), + POINTER(c_long), + POINTER(c_long), + POINTER(c_long), + POINTER(c_long), + POINTER(c_long), + POINTER(c_float), + ) + core_cdll.yukarin_sa_forward.restype = c_bool + + +def _type_decode_forward(core_cdll: CDLL) -> None: + """ + コアDLL `decode_forward` 関数の型付け + Parameters + ---------- + core_cdll : CDLL + コアDLL + """ + core_cdll.decode_forward.argtypes = ( + c_int, + c_int, + POINTER(c_float), + POINTER(c_float), + POINTER(c_long), + POINTER(c_float), + ) + core_cdll.decode_forward.restype = c_bool + + class CoreWrapper: def __init__( self, @@ -393,9 +451,9 @@ def __init__( self.core.initialize.restype = c_bool self.core.metas.restype = c_char_p - self.core.yukarin_s_forward.restype = c_bool - self.core.yukarin_sa_forward.restype = c_bool - self.core.decode_forward.restype = c_bool + _type_yukarin_s_forward(self.core) + _type_yukarin_sa_forward(self.core) + _type_decode_forward(self.core) self.core.last_error_message.restype = c_char_p self.exist_supported_devices = False @@ -426,32 +484,6 @@ def __init__( self.exist_finalize = True exist_cpu_num_threads = True - self.core.yukarin_s_forward.argtypes = ( - c_int, - POINTER(c_long), - POINTER(c_long), - POINTER(c_float), - ) - self.core.yukarin_sa_forward.argtypes = ( - c_int, - POINTER(c_long), - POINTER(c_long), - POINTER(c_long), - POINTER(c_long), - POINTER(c_long), - POINTER(c_long), - POINTER(c_long), - POINTER(c_float), - ) - self.core.decode_forward.argtypes = ( - c_int, - c_int, - POINTER(c_float), - POINTER(c_float), - POINTER(c_long), - POINTER(c_float), - ) - cwd = os.getcwd() os.chdir(core_dir) try: