From 689217e35067bf860c5ec8a2d7e22024aefe64cd Mon Sep 17 00:00:00 2001 From: tsukumi Date: Sun, 10 Nov 2024 07:11:53 +0900 Subject: [PATCH] Refactor: TTSModel.convert_to_16_bit_wav() to @staticmethod --- style_bert_vits2/tts_model.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/style_bert_vits2/tts_model.py b/style_bert_vits2/tts_model.py index 10bf25f..1351db7 100644 --- a/style_bert_vits2/tts_model.py +++ b/style_bert_vits2/tts_model.py @@ -308,7 +308,8 @@ class TTSModel: xvec = mean + (xvec - mean) * weight return xvec - def convert_to_16_bit_wav(self, data: NDArray[Any]) -> NDArray[Any]: + @staticmethod + def convert_to_16_bit_wav(data: NDArray[Any]) -> NDArray[Any]: """ 音声データを 16-bit int 形式に変換する。 gradio.processing_utils.convert_to_16_bit_wav() を移植したもの。 @@ -319,6 +320,7 @@ class TTSModel: Returns: NDArray[Any]: 16-bit int 形式の音声データ """ + # Based on: https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.wavfile.write.html if data.dtype in [np.float64, np.float32, np.float16]: # type: ignore data = data / np.abs(data).max() @@ -343,6 +345,7 @@ class TTSModel: "Audio data cannot be converted automatically from " f"{data.dtype} to 16-bit int format." ) + return data def infer(