diff --git a/server/sio/MMVC_SocketIOApp.py b/server/sio/MMVC_SocketIOApp.py index 51db4c5d..ed9ae2dc 100644 --- a/server/sio/MMVC_SocketIOApp.py +++ b/server/sio/MMVC_SocketIOApp.py @@ -5,34 +5,36 @@ from voice_changer.VoiceChangerManager import VoiceChangerManager from const import getFrontendPath -class MMVC_SocketIOApp(): +class MMVC_SocketIOApp: + _instance: socketio.ASGIApp | None = None + @classmethod def get_instance(cls, app_fastapi, voiceChangerManager: VoiceChangerManager): - if not hasattr(cls, "_instance"): + if cls._instance is None: sio = MMVC_SocketIOServer.get_instance(voiceChangerManager) app_socketio = socketio.ASGIApp( sio, other_asgi_app=app_fastapi, static_files={ - '/assets/icons/github.svg': { - 'filename': f'{getFrontendPath()}/assets/icons/github.svg', - 'content_type': 'image/svg+xml' + "/assets/icons/github.svg": { + "filename": f"{getFrontendPath()}/assets/icons/github.svg", + "content_type": "image/svg+xml", }, - '/assets/icons/help-circle.svg': { - 'filename': f'{getFrontendPath()}/assets/icons/help-circle.svg', - 'content_type': 'image/svg+xml' + "/assets/icons/help-circle.svg": { + "filename": f"{getFrontendPath()}/assets/icons/help-circle.svg", + "content_type": "image/svg+xml", }, - '/assets/icons/tool.svg': { - 'filename': f'{getFrontendPath()}/assets/icons/tool.svg', - 'content_type': 'image/svg+xml' + "/assets/icons/tool.svg": { + "filename": f"{getFrontendPath()}/assets/icons/tool.svg", + "content_type": "image/svg+xml", }, - '/buymeacoffee.png': { - 'filename': f'{getFrontendPath()}/assets/buymeacoffee.png', - 'content_type': 'image/png' + "/buymeacoffee.png": { + "filename": f"{getFrontendPath()}/assets/buymeacoffee.png", + "content_type": "image/png", }, - '': f'{getFrontendPath()}', - '/': f'{getFrontendPath()}/index.html', - } + "": f"{getFrontendPath()}", + "/": f"{getFrontendPath()}/index.html", + }, ) cls._instance = app_socketio diff --git a/server/sio/MMVC_SocketIOServer.py b/server/sio/MMVC_SocketIOServer.py index 31a252e6..9f7c0267 100644 --- a/server/sio/MMVC_SocketIOServer.py +++ b/server/sio/MMVC_SocketIOServer.py @@ -3,18 +3,17 @@ import socketio from sio.MMVC_Namespace import MMVC_Namespace from voice_changer.VoiceChangerManager import VoiceChangerManager -class MMVC_SocketIOServer(): + +class MMVC_SocketIOServer: + _instance: socketio.AsyncServer | None = None + @classmethod - def get_instance(cls, voiceChangerManager:VoiceChangerManager): + def get_instance(cls, voiceChangerManager: VoiceChangerManager): if not hasattr(cls, "_instance"): - sio = socketio.AsyncServer( - async_mode='asgi', - cors_allowed_origins='*' - ) + sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins="*") namespace = MMVC_Namespace.get_instance(voiceChangerManager) sio.register_namespace(namespace) cls._instance = sio return cls._instance return cls._instance - diff --git a/server/voice_changer/RVC/RVC.py b/server/voice_changer/RVC/RVC.py index 16cbf01a..87f65b2a 100644 --- a/server/voice_changer/RVC/RVC.py +++ b/server/voice_changer/RVC/RVC.py @@ -325,9 +325,6 @@ class RVC: dev = self.deviceManager.getDevice(self.settings.gpu) half = self.deviceManager.halfPrecisionAvailable(self.settings.gpu) - # self.embedder = self.embedder.setDevice(dev) - # self.inferencer = self.inferencer.setDevice(dev) - audio = data[0] convertSize = data[1] vol = data[2] @@ -365,11 +362,6 @@ class RVC: result = audio_out * np.sqrt(vol) - # if self.settings.framework == "ONNX": - # audio = self._onnx_inference(data) - # else: - # audio = self._pyTorch_inference(data) - return result def __del__(self):