mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 21:45:00 +03:00
improve half precision check, and fallback(exp.)
This commit is contained in:
parent
35230d3a59
commit
605e04f48f
@ -31,3 +31,8 @@ class ONNXInputArgumentException(Exception):
|
|||||||
class DeviceCannotSupportHalfPrecisionException(Exception):
|
class DeviceCannotSupportHalfPrecisionException(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr("Device cannot support half precision.")
|
return repr("Device cannot support half precision.")
|
||||||
|
|
||||||
|
|
||||||
|
class VoiceChangerIsNotSelectedException(Exception):
|
||||||
|
def __str__(self):
|
||||||
|
return repr("Voice Changer is not selected.")
|
||||||
|
@ -131,7 +131,7 @@ class Pipeline(object):
|
|||||||
padding_mask = torch.BoolTensor(feats.shape).to(self.device).fill_(False)
|
padding_mask = torch.BoolTensor(feats.shape).to(self.device).fill_(False)
|
||||||
try:
|
try:
|
||||||
feats = self.embedder.extractFeatures(feats, embOutputLayer, useFinalProj)
|
feats = self.embedder.extractFeatures(feats, embOutputLayer, useFinalProj)
|
||||||
if all(i is None for i in feats):
|
if torch.isnan(feats).all():
|
||||||
raise DeviceCannotSupportHalfPrecisionException()
|
raise DeviceCannotSupportHalfPrecisionException()
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
if "HALF" in e.__str__().upper():
|
if "HALF" in e.__str__().upper():
|
||||||
|
@ -22,6 +22,7 @@ from Exceptions import (
|
|||||||
NoModeLoadedException,
|
NoModeLoadedException,
|
||||||
NotEnoughDataExtimateF0,
|
NotEnoughDataExtimateF0,
|
||||||
ONNXInputArgumentException,
|
ONNXInputArgumentException,
|
||||||
|
VoiceChangerIsNotSelectedException,
|
||||||
)
|
)
|
||||||
from voice_changer.utils.VoiceChangerParams import VoiceChangerParams
|
from voice_changer.utils.VoiceChangerParams import VoiceChangerParams
|
||||||
import threading
|
import threading
|
||||||
@ -326,7 +327,9 @@ class VoiceChanger:
|
|||||||
def loadModel(self, props: LoadModelParams):
|
def loadModel(self, props: LoadModelParams):
|
||||||
try:
|
try:
|
||||||
if self.voiceChanger is None:
|
if self.voiceChanger is None:
|
||||||
raise RuntimeError("Voice Changer is not selected.")
|
raise VoiceChangerIsNotSelectedException(
|
||||||
|
"Voice Changer is not selected."
|
||||||
|
)
|
||||||
return self.voiceChanger.loadModel(props)
|
return self.voiceChanger.loadModel(props)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
@ -432,7 +435,9 @@ class VoiceChanger:
|
|||||||
) -> tuple[AudioInOut, list[Union[int, float]]]:
|
) -> tuple[AudioInOut, list[Union[int, float]]]:
|
||||||
try:
|
try:
|
||||||
if self.voiceChanger is None:
|
if self.voiceChanger is None:
|
||||||
raise RuntimeError("Voice Changer is not selected.")
|
raise VoiceChangerIsNotSelectedException(
|
||||||
|
"Voice Changer is not selected."
|
||||||
|
)
|
||||||
|
|
||||||
processing_sampling_rate = self.voiceChanger.get_processing_sampling_rate()
|
processing_sampling_rate = self.voiceChanger.get_processing_sampling_rate()
|
||||||
# 前処理
|
# 前処理
|
||||||
@ -570,8 +575,11 @@ class VoiceChanger:
|
|||||||
except DeviceChangingException as e:
|
except DeviceChangingException as e:
|
||||||
print("[Voice Changer] embedder:", e)
|
print("[Voice Changer] embedder:", e)
|
||||||
return np.zeros(1).astype(np.int16), [0, 0, 0]
|
return np.zeros(1).astype(np.int16), [0, 0, 0]
|
||||||
|
except VoiceChangerIsNotSelectedException:
|
||||||
|
print("[Voice Changer] Voice Changer is not selected. please re-select vc.")
|
||||||
|
return np.zeros(1).astype(np.int16), [0, 0, 0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("VC PROCESSING!!!! EXCEPTION!!!", e)
|
print("[Voice Changer] VC PROCESSING EXCEPTION!!!", e)
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
return np.zeros(1).astype(np.int16), [0, 0, 0]
|
return np.zeros(1).astype(np.int16), [0, 0, 0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user