WIP: refactor

This commit is contained in:
w-okada 2023-07-15 23:39:02 +09:00
parent 33e156ef9a
commit 9eef8fcb11
4 changed files with 34 additions and 10 deletions

View File

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

View File

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

View File

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

View 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:
...