Some small modifications

This commit is contained in:
wataru 2023-05-04 12:29:12 +09:00
parent 3726a926b7
commit 6f1b06a419
3 changed files with 25 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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):