Refactor: remove dependencies on libraries not required for style_bert_vits2 as a library
librosa: Originally not used under style_bert_vits2/. pyannote.audio: Required only when using the "infer style vector from audio" function during inference, but it is currently almost unused. scipy: Because it was used in only one utility function that was not needed outside of training.
This commit is contained in:
@@ -9,7 +9,6 @@ from typing import TYPE_CHECKING, Any, Optional, Union
|
||||
import numpy as np
|
||||
import torch
|
||||
from numpy.typing import NDArray
|
||||
from scipy.io.wavfile import read
|
||||
|
||||
from style_bert_vits2.logging import logger
|
||||
from style_bert_vits2.models.utils import checkpoints # type: ignore
|
||||
@@ -162,6 +161,13 @@ def load_wav_to_torch(full_path: Union[str, Path]) -> tuple[torch.FloatTensor, i
|
||||
tuple[torch.FloatTensor, int]: 音声データのテンソルとサンプリングレート
|
||||
"""
|
||||
|
||||
# この関数は学習時以外使われないため、ライブラリとしての style_bert_vits2 が
|
||||
# 重たい scipy に依存しないように遅延 import する
|
||||
try:
|
||||
from scipy.io.wavfile import read
|
||||
except ImportError:
|
||||
raise ImportError("scipy is required to load wav file")
|
||||
|
||||
sampling_rate, data = read(full_path)
|
||||
return torch.FloatTensor(data.astype(np.float32)), sampling_rate
|
||||
|
||||
|
||||
Reference in New Issue
Block a user