mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-02-03 00:33:57 +03:00
22 lines
817 B
Python
22 lines
817 B
Python
|
import numpy as np
|
||
|
from mods.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):
|
||
|
if hasattr(self, 'voiceChanger') == True:
|
||
|
self.voiceChanger.destroy()
|
||
|
self.voiceChanger = VoiceChanger(config, model)
|
||
|
|
||
|
def changeVoice(self, gpu, srcId, dstId, timestamp, prefixChunkSize, unpackedData):
|
||
|
if hasattr(self, 'voiceChanger') == True:
|
||
|
return self.voiceChanger.on_request(gpu, srcId, dstId, timestamp, prefixChunkSize, unpackedData)
|
||
|
else:
|
||
|
print("Voice Change is not loaded. Did you load a correct model?")
|
||
|
return np.zeros(1).astype(np.int16)
|