mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 21:45:00 +03:00
WIP: refactor
This commit is contained in:
parent
33e156ef9a
commit
9eef8fcb11
@ -12,6 +12,7 @@ import onnxruntime
|
||||
from voice_changer.IORecorder import IORecorder
|
||||
|
||||
from voice_changer.utils.Timer import Timer
|
||||
from voice_changer.utils.VoiceChangerIF import VoiceChangerIF
|
||||
from voice_changer.utils.VoiceChangerModel import AudioInOut, VoiceChangerModel
|
||||
from Exceptions import (
|
||||
DeviceCannotSupportHalfPrecisionException,
|
||||
@ -59,7 +60,7 @@ class VoiceChangerSettings:
|
||||
strData: list[str] = field(default_factory=lambda: [])
|
||||
|
||||
|
||||
class VoiceChanger:
|
||||
class VoiceChanger(VoiceChangerIF):
|
||||
ioRecorder: IORecorder
|
||||
sola_buffer: AudioInOut
|
||||
|
||||
@ -83,9 +84,6 @@ class VoiceChanger:
|
||||
def setModel(self, model: Any):
|
||||
self.voiceChanger = model
|
||||
|
||||
def getModelType(self):
|
||||
return {"status": "OK", "vc": "-----"}
|
||||
|
||||
def get_info(self):
|
||||
data = asdict(self.settings)
|
||||
if self.voiceChanger is not None:
|
||||
|
@ -280,9 +280,6 @@ class VoiceChangerManager(ServerDeviceCallbacks):
|
||||
print("Voice Change is not loaded. Did you load a correct model?")
|
||||
return np.zeros(1).astype(np.int16), []
|
||||
|
||||
def getModelType(self):
|
||||
return self.voiceChanger.getModelType()
|
||||
|
||||
def export2onnx(self):
|
||||
return self.voiceChanger.export2onnx()
|
||||
|
||||
|
@ -22,6 +22,7 @@ import onnxruntime
|
||||
from voice_changer.IORecorder import IORecorder
|
||||
|
||||
from voice_changer.utils.Timer import Timer
|
||||
from voice_changer.utils.VoiceChangerIF import VoiceChangerIF
|
||||
from voice_changer.utils.VoiceChangerModel import AudioInOut, VoiceChangerModel
|
||||
from Exceptions import (
|
||||
DeviceCannotSupportHalfPrecisionException,
|
||||
@ -69,7 +70,7 @@ class VoiceChangerV2Settings:
|
||||
strData: list[str] = field(default_factory=lambda: [])
|
||||
|
||||
|
||||
class VoiceChangerV2:
|
||||
class VoiceChangerV2(VoiceChangerIF):
|
||||
ioRecorder: IORecorder
|
||||
sola_buffer: AudioInOut
|
||||
|
||||
|
28
server/voice_changer/utils/VoiceChangerIF.py
Normal file
28
server/voice_changer/utils/VoiceChangerIF.py
Normal file
@ -0,0 +1,28 @@
|
||||
from typing import Any, Protocol
|
||||
|
||||
from voice_changer.utils.VoiceChangerModel import AudioInOut, VoiceChangerModel
|
||||
|
||||
|
||||
class VoiceChangerIF(Protocol):
|
||||
|
||||
def get_processing_sampling_rate() -> int:
|
||||
...
|
||||
|
||||
def get_info(self) -> dict[str, Any]:
|
||||
...
|
||||
|
||||
def get_performance(self) -> list[int]:
|
||||
...
|
||||
|
||||
def setModel(model: VoiceChangerModel) -> None:
|
||||
...
|
||||
|
||||
def update_settings(self, key: str, val: int | float | str) -> bool:
|
||||
...
|
||||
|
||||
def on_request(receivedData: AudioInOut) -> tuple[AudioInOut, list[int | float]]:
|
||||
...
|
||||
|
||||
def export2onnx() -> Any:
|
||||
...
|
||||
|
Loading…
Reference in New Issue
Block a user