improve half precision check, and fallback(exp.)

This commit is contained in:
wataru 2023-06-03 18:05:10 +09:00
parent 28fa21a6b4
commit 9d6ae2fe2e
2 changed files with 10 additions and 4 deletions

View File

@ -377,16 +377,18 @@ class RVC:
repeat,
protect,
)
except DeviceCannotSupportHalfPrecisionException:
result = audio_out.detach().cpu().numpy() * np.sqrt(vol)
return result
except DeviceCannotSupportHalfPrecisionException as e:
print(
"[Device Manager] Device cannot support half precision. Fallback to float...."
)
self.deviceManager.setForceTensor(True)
self.prepareModel(self.settings.modelSlotIndex)
raise e
result = audio_out.detach().cpu().numpy() * np.sqrt(vol)
return result
return
def __del__(self):
del self.pipeline

View File

@ -17,6 +17,7 @@ from voice_changer.utils.LoadModelParams import LoadModelParams
from voice_changer.utils.Timer import Timer
from voice_changer.utils.VoiceChangerModel import VoiceChangerModel, AudioInOut
from Exceptions import (
DeviceCannotSupportHalfPrecisionException,
DeviceChangingException,
HalfPrecisionChangingException,
NoModeLoadedException,
@ -580,6 +581,9 @@ class VoiceChanger:
"[Voice Changer] Voice Changer is not selected. Wait a bit and if there is no improvement, please re-select vc."
)
return np.zeros(1).astype(np.int16), [0, 0, 0]
except DeviceCannotSupportHalfPrecisionException:
# RVC.pyでfallback処理をするので、ここはダミーデータ返すだけ。
return np.zeros(1).astype(np.int16), [0, 0, 0]
except Exception as e:
print("[Voice Changer] VC PROCESSING EXCEPTION!!!", e)
print(traceback.format_exc())