import numpy as np from voice_changer.VoiceChanger import VoiceChanger class VoiceChangerManager(): @classmethod def get_instance(cls, params): if not hasattr(cls, "_instance"): cls._instance = cls() cls._instance.voiceChanger = VoiceChanger(params) return cls._instance def loadModel(self, config, model, onnx_model, clusterTorchModel): info = self.voiceChanger.loadModel(config, model, onnx_model, clusterTorchModel) 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, receivedData: any): if hasattr(self, 'voiceChanger') == True: return self.voiceChanger.on_request(receivedData) else: print("Voice Change is not loaded. Did you load a correct model?") return np.zeros(1).astype(np.int16), []