Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: copy and refacotor the code from DDSP_SVC #1017

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/demo/dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
},
"dependencies": {
"@alexanderolsen/libsamplerate-js": "^2.1.0",
"@babel/runtime": "^7.23.4",
"@dannadori/voice-changer-client-js": "^1.0.177",
"@dannadori/voice-changer-js": "^1.0.2",
"@dannadori/worker-manager": "^1.0.20",
Expand Down
6 changes: 0 additions & 6 deletions client/demo/src/components/demo/904-3_FileUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ export const FileUploaderScreen = (props: FileUploaderScreenProps) => {
return enough;
} else if (setting.voiceChangerType == "DDSP-SVC") {
const enough =
!!setting.files.find((x) => {
return x.kind == "ddspSvcModel";
}) &&
!!setting.files.find((x) => {
return x.kind == "ddspSvcModelConfig";
}) &&
!!setting.files.find((x) => {
return x.kind == "ddspSvcDiffusion";
}) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useGuiState } from "../001_GuiStateProvider";
import { useMessageBuilder } from "../../../hooks/useMessageBuilder";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useAppRoot } from "../../../001_provider/001_AppRootProvider";
import { DDSPSVCModelSlot } from "@dannadori/voice-changer-client-js";

export type ModelSlotAreaProps = {};

Expand Down Expand Up @@ -32,8 +33,8 @@ export const ModelSlotArea = (_props: ModelSlotAreaProps) => {
sortType == "slot"
? serverSetting.serverSetting.modelSlots
: serverSetting.serverSetting.modelSlots.slice().sort((a, b) => {
return a.name.localeCompare(b.name);
});
return a.name.localeCompare(b.name);
});

return modelSlots
.map((x, index) => {
Expand Down
3 changes: 3 additions & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ websockets==11.0.2
sounddevice==0.4.6
dataclasses_json==0.5.7
onnxsim==0.4.28
diffusion==6.10.1
transformers==4.35.2
# praat-parselmouth==0.4.3
22 changes: 11 additions & 11 deletions server/voice_changer/DDSP_SVC/DDSP_SVC.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, params: VoiceChangerParams, slotInfo: DDSPSVCModelSlot):
self.params = params
self.settings = DDSP_SVCSettings()
self.svc_model: SvcDDSP = SvcDDSP()
self.diff_model: DiffGtMel = DiffGtMel()
# self.diff_model: DiffGtMel = DiffGtMel()

self.svc_model.setVCParams(params)
EmbedderManager.initialize(params)
Expand All @@ -81,19 +81,19 @@ def initialize(self):
str(self.slotInfo.slotIndex),
"model",
self.slotInfo.modelFile,
)
) if self.slotInfo.modelFile != 'builtin' else self.slotInfo.modelFile
diffPath = os.path.join(
vcparams.model_dir,
str(self.slotInfo.slotIndex),
"diff",
self.slotInfo.diffModelFile,
)

self.svc_model = SvcDDSP()
self.svc_model.setVCParams(self.params)
self.svc_model.update_model(modelPath, self.device)
self.diff_model = DiffGtMel(device=self.device)
self.diff_model.flush_model(diffPath, ddsp_config=self.svc_model.args)
self.svc_model.update_model(modelPath, diffPath , self.device)
# self.diff_model = DiffGtMel(device=self.device)
# self.diff_model.flush_model(diffPath, ddsp_config=self.svc_model.args)

def update_settings(self, key: str, val: int | float | str):
if key in self.settings.intData:
Expand Down Expand Up @@ -161,19 +161,19 @@ def _pyTorch_inference(self, data):
pitch_adjust=self.settings.tran,
use_spk_mix=False,
spk_mix_dict=None,
use_enhancer=True if self.settings.useEnhancer == 1 else False,
# use_enhancer=True if self.settings.useEnhancer == 1 else False,
pitch_extractor_type=self.settings.f0Detector,
f0_min=50,
f0_max=1100,
# safe_prefix_pad_length=0, # TBD なにこれ?
safe_prefix_pad_length=self.settings.extraConvertSize
/ self.svc_model.args.data.sampling_rate,
diff_model=self.diff_model,
# diff_model=self.diff_model,
diff_acc=self.settings.diffAcc, # TBD なにこれ?
diff_spk_id=self.settings.diffSpkId,
diff_use=True if self.settings.useDiff == 1 else False,
# diff_spk_id=self.settings.diffSpkId,
# diff_use=True if self.settings.useDiff == 1 else False,
# diff_use_dpm=True if self.settings.useDiffDpm == 1 else False, # TBD なにこれ?
method=self.settings.diffMethod,
diff_method=self.settings.diffMethod,
k_step=self.settings.kStep, # TBD なにこれ?
diff_silence=True
if self.settings.useDiffSilence == 1
Expand Down
6 changes: 5 additions & 1 deletion server/voice_changer/DDSP_SVC/DDSP_SVCModelSlotGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def loadModel(cls, props: LoadModelParams):
slotInfo.diffConfigFile = file.name
elif file.kind == "ddspSvcDiffusion":
slotInfo.diffModelFile = file.name
if slotInfo.configFile == '':
slotInfo.configFile = 'builtin'
if slotInfo.modelFile == '':
slotInfo.modelFile = 'builtin'
slotInfo.isONNX = slotInfo.modelFile.endswith(".onnx")
slotInfo.name = os.path.splitext(os.path.basename(slotInfo.modelFile))[0]
slotInfo.name = os.path.splitext(os.path.basename(slotInfo.diffModelFile))[0]
return slotInfo
12 changes: 6 additions & 6 deletions server/voice_changer/DDSP_SVC/DDSP_SVCSetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class DDSP_SVCSettings:
silentThreshold: float = 0.00001
extraConvertSize: int = 1024 * 32

useEnhancer: int = 0
useDiff: int = 1
# useEnhancer: int = 0
# useDiff: int = 1
# useDiffDpm: int = 0
diffMethod: str = "dpm-solver" # "pndm", "dpm-solver"
useDiffSilence: int = 0
diffAcc: int = 20
diffSpkId: int = 1
# diffSpkId: int = 1
kStep: int = 120
threshold: int = -45

Expand All @@ -28,12 +28,12 @@ class DDSP_SVCSettings:
"dstId",
"tran",
"extraConvertSize",
"useEnhancer",
"useDiff",
# "useEnhancer",
# "useDiff",
# "useDiffDpm",
"useDiffSilence",
"diffAcc",
"diffSpkId",
# "diffSpkId",
"kStep",
]
floatData = ["silentThreshold"]
Expand Down
Loading
Loading