WIP: support so-vits-svc 40v2. dstID list from server.

This commit is contained in:
wataru 2023-03-14 10:44:05 +09:00
parent 1f33cd547d
commit 39fab4afc1
5 changed files with 28 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -57,6 +57,7 @@ export const useModelSettingArea = (): ServerSettingState => {
file: file
}
})
}
const onConfigFileClearClicked = () => {
appState.serverSetting.setFileUploadSetting({

View File

@ -1,3 +1,4 @@
import { ServerInfoSoVitsSVC } from "@dannadori/voice-changer-client-js";
import React, { useMemo, useState } from "react"
import { useAppState } from "./001_provider/001_AppStateProvider";
import { AnimationTypes, HeaderButton, HeaderButtonProps } from "./components/101_HeaderButton";
@ -5,6 +6,7 @@ import { AnimationTypes, HeaderButton, HeaderButtonProps } from "./components/10
export const useSpeakerSetting = () => {
const appState = useAppState()
const accodionButton = useMemo(() => {
const accodionButtonProps: HeaderButtonProps = {
stateControlCheckbox: appState.frontendManagerState.stateControls.openSpeakerSettingCheckbox,
@ -18,17 +20,26 @@ export const useSpeakerSetting = () => {
}, []);
const dstIdRow = useMemo(() => {
const settings = appState.serverSetting.serverSetting as ServerInfoSoVitsSVC
const speakers = settings.speakers
if (!speakers) {
return <></>
}
const currentValue = Object.values(speakers).includes(appState.serverSetting.serverSetting.dstId) ? appState.serverSetting.serverSetting.dstId : -1
return (
<div className="body-row split-3-2-1-4 left-padding-1 guided">
<div className="body-item-title left-padding-1">Destination Speaker Id</div>
<div className="body-select-container">
<select className="body-select" value={appState.serverSetting.serverSetting.dstId} onChange={(e) => {
<select className="body-select" value={currentValue} onChange={(e) => {
appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, dstId: Number(e.target.value) })
}}>
<option key="unknown" value={-1}>unknwon(-1)</option>
{
[0, 1, 2, 3, 4].map(x => {
return <option key={x} value={x}>{x}</option>
Object.keys(speakers).map(x => {
return <option key={x} value={speakers[x]}>{x}({speakers[x]})</option>
})
}
</select>

View File

@ -112,6 +112,9 @@ export type ServerInfo = VoiceChangerServerSetting & {
onnxExecutionProviders: OnnxExecutionProvider[]
}
export type ServerInfoSoVitsSVC = ServerInfo & {
speakers: { [key: string]: number }
}
export const DefaultServerSetting_MMVCv15: ServerInfo = {
srcId: 0,
dstId: 101,

View File

@ -11,7 +11,7 @@ else:
sys.path.append("so-vits-svc-40v2")
import io
from dataclasses import dataclass, asdict
from dataclasses import dataclass, asdict, field
from functools import reduce
import numpy as np
import torch
@ -29,7 +29,7 @@ providers = ['OpenVINOExecutionProvider', "CUDAExecutionProvider", "DmlExecution
@dataclass
class SoVitsSvc40v2Settings():
gpu: int = 0
dstId: int = 0
dstId: int = -1
f0Detector: str = "dio" # dio or harvest
tran: int = 20
@ -44,6 +44,10 @@ class SoVitsSvc40v2Settings():
onnxModelFile: str = ""
configFile: str = ""
speakers: dict[str, int] = field(
default_factory=lambda: {}
)
# ↓mutableな物だけ列挙
intData = ["gpu", "dstId", "tran", "predictF0", "extraConvertSize"]
floatData = ["noiceScale", "silentThreshold", "clusterInferRatio"]
@ -65,38 +69,30 @@ class SoVitsSvc40v2:
self.settings.configFile = config
self.hps = utils.get_hparams_from_file(config)
self.settings.speakers = self.hps.spk
# hubert model
try:
# vec_path = hubertTorchModel
vec_path = "hubert/checkpoint_best_legacy_500.pt"
print("hubert 1 ", hubertTorchModel)
models, saved_cfg, task = checkpoint_utils.load_model_ensemble_and_task(
[vec_path],
suffix="",
)
print("hubert 2 ", hubertTorchModel)
model = models[0]
print("hubert 3 ", hubertTorchModel)
model.eval()
print("hubert 4 ", hubertTorchModel)
self.hubert_model = model.cpu()
print("hubert 5 ", hubertTorchModel)
except Exception as e:
print("EXCEPTION1", e)
print("EXCEPTION during loading hubert/contentvec model", e)
# cluster
try:
if os.path.exists(clusterTorchModel):
print("load kmean11", clusterTorchModel)
self.cluster_model = cluster.get_cluster_model(clusterTorchModel)
print("load kmean12", clusterTorchModel)
else:
print("load kmean21", clusterTorchModel)
self.cluster_model = None
print("load kmean22", clusterTorchModel)
except Exception as e:
print("EXCEPTION2", e)
print("EXCEPTION during loading cluster model ", e)
if pyTorch_model_file != None:
self.settings.pyTorchModelFile = pyTorch_model_file