mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-24 05:55:01 +03:00
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import numpy as np
|
|
from voice_changer.VoiceChanger import VoiceChanger
|
|
|
|
class VoiceChangerManager():
|
|
@classmethod
|
|
def get_instance(cls):
|
|
if not hasattr(cls, "_instance"):
|
|
cls._instance = cls()
|
|
return cls._instance
|
|
|
|
def loadModel(self, config, model, onnx_model):
|
|
if hasattr(self, 'voiceChanger') == False:
|
|
self.voiceChanger = VoiceChanger(config)
|
|
info = self.voiceChanger.loadModel(config, model, onnx_model)
|
|
info["status"]="OK"
|
|
return info
|
|
|
|
def get_info(self):
|
|
if hasattr(self, 'voiceChanger'):
|
|
info = self.voiceChanger.get_info()
|
|
info["status"]="OK"
|
|
return info
|
|
else:
|
|
return {"status":"ERROR", "msg":"no model loaded"}
|
|
|
|
def update_setteings(self, key:str, val:any):
|
|
if hasattr(self, 'voiceChanger'):
|
|
info = self.voiceChanger.update_setteings(key, val)
|
|
info["status"]="OK"
|
|
return info
|
|
else:
|
|
return {"status":"ERROR", "msg":"no model loaded"}
|
|
|
|
def changeVoice(self, unpackedData:any):
|
|
if hasattr(self, 'voiceChanger') == True:
|
|
return self.voiceChanger.on_request(unpackedData)
|
|
else:
|
|
print("Voice Change is not loaded. Did you load a correct model?")
|
|
return np.zeros(1).astype(np.int16)
|