mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 13:35:12 +03:00
support model merge
This commit is contained in:
parent
17521975c1
commit
e7b3a38402
2
client/demo/dist/index.js
vendored
2
client/demo/dist/index.js
vendored
File diff suppressed because one or more lines are too long
14
client/demo/package-lock.json
generated
14
client/demo/package-lock.json
generated
@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@dannadori/voice-changer-client-js": "^1.0.119",
|
||||
"@dannadori/voice-changer-client-js": "^1.0.120",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
||||
"@fortawesome/free-brands-svg-icons": "^6.4.0",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.4.0",
|
||||
@ -3105,9 +3105,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@dannadori/voice-changer-client-js": {
|
||||
"version": "1.0.119",
|
||||
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.119.tgz",
|
||||
"integrity": "sha512-22QbFjLVyO1cXMEzwTzjTPotLP8F/WLXrtduwVUseeDPvO0l+DW0vgjVK/rZQ4OT1Eflgnliymiuj/7lSCzuJQ==",
|
||||
"version": "1.0.120",
|
||||
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.120.tgz",
|
||||
"integrity": "sha512-h1WilCcVuZl9iKiQzUA9tT5/R905kw9O5lZwbHGfdo/R4kB4BblJuj65cO02Gu4/K050GCm3k0oJ1Sslz3XZlg==",
|
||||
"dependencies": {
|
||||
"@types/readable-stream": "^2.3.15",
|
||||
"amazon-chime-sdk-js": "^3.13.0",
|
||||
@ -12807,9 +12807,9 @@
|
||||
}
|
||||
},
|
||||
"@dannadori/voice-changer-client-js": {
|
||||
"version": "1.0.119",
|
||||
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.119.tgz",
|
||||
"integrity": "sha512-22QbFjLVyO1cXMEzwTzjTPotLP8F/WLXrtduwVUseeDPvO0l+DW0vgjVK/rZQ4OT1Eflgnliymiuj/7lSCzuJQ==",
|
||||
"version": "1.0.120",
|
||||
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.120.tgz",
|
||||
"integrity": "sha512-h1WilCcVuZl9iKiQzUA9tT5/R905kw9O5lZwbHGfdo/R4kB4BblJuj65cO02Gu4/K050GCm3k0oJ1Sslz3XZlg==",
|
||||
"requires": {
|
||||
"@types/readable-stream": "^2.3.15",
|
||||
"amazon-chime-sdk-js": "^3.13.0",
|
||||
|
@ -51,7 +51,7 @@
|
||||
"webpack-dev-server": "^4.13.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dannadori/voice-changer-client-js": "^1.0.119",
|
||||
"@dannadori/voice-changer-client-js": "^1.0.120",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
||||
"@fortawesome/free-brands-svg-icons": "^6.4.0",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.4.0",
|
||||
|
@ -22,6 +22,9 @@ export const ClearSettingRow = (_props: ClearSettingRowProps) => {
|
||||
await removeItem(INDEXEDDB_KEY_AUDIO_OUTPUT)
|
||||
location.reload()
|
||||
}
|
||||
const onReloadClicked = async () => {
|
||||
location.reload()
|
||||
}
|
||||
const onReselectVCClicked = async () => {
|
||||
guiState.setIsConverting(false)
|
||||
if (guiState.isConverting) {
|
||||
@ -37,6 +40,7 @@ export const ClearSettingRow = (_props: ClearSettingRowProps) => {
|
||||
<div className="body-row split-2-2-6 left-padding-1">
|
||||
<div className="body-button-container">
|
||||
<div className="body-button" onClick={onClearSettingClicked}>clear setting</div>
|
||||
<div className="body-button" onClick={onReloadClicked}>reload</div>
|
||||
</div>
|
||||
<div className="body-button-container">
|
||||
<div className="body-button" onClick={onReselectVCClicked}>re-select vc</div>
|
||||
|
@ -18,6 +18,9 @@ export const ModelSwitchRow = (_props: ModelSwitchRowProps) => {
|
||||
// Quick hack for same slot is selected. 下3桁が実際のSlotID
|
||||
const dummyModelSlotIndex = (Math.floor(Date.now() / 1000)) * 1000 + index
|
||||
await appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, modelSlotIndex: dummyModelSlotIndex, framework: framework })
|
||||
setTimeout(() => { // quick hack
|
||||
appState.getInfo()
|
||||
}, 1000 * 2)
|
||||
}
|
||||
const modelOptions = appState.serverSetting.serverSetting.modelSlots.map((x, index) => {
|
||||
const className = index == slot ? "body-button-active left-margin-1" : "body-button left-margin-1"
|
||||
|
@ -10,18 +10,22 @@ export type MergeLabRowProps = {
|
||||
export const MergeLabRow = (_props: MergeLabRowProps) => {
|
||||
const [mergeElements, setMergeElements] = useState<MergeElement[]>([])
|
||||
const appState = useAppState()
|
||||
const [defaultTrans, setDefaultTrans] = useState<number>(0)
|
||||
|
||||
// スロットが変更されたときの初期化処理
|
||||
const newSlotChangeKey = useMemo(() => {
|
||||
console.log("appState.serverSetting.serverSetting.modelSlots", appState.serverSetting.serverSetting.modelSlots)
|
||||
return appState.serverSetting.serverSetting.modelSlots.reduce((prev, cur) => {
|
||||
return prev + "_" + cur.pyTorchModelFile
|
||||
}, "")
|
||||
}, [appState.serverSetting.serverSetting.modelSlots])
|
||||
|
||||
console.log("newSlotChangeKey", newSlotChangeKey)
|
||||
useEffect(() => {
|
||||
// PyTorchモデルだけフィルタリング
|
||||
const models = appState.serverSetting.serverSetting.modelSlots.filter(x => { return x.pyTorchModelFile && x.pyTorchModelFile.length > 0 })
|
||||
if (models.length == 0) {
|
||||
setMergeElements([])
|
||||
return
|
||||
}
|
||||
|
||||
@ -45,10 +49,11 @@ export const MergeLabRow = (_props: MergeLabRowProps) => {
|
||||
}, [newSlotChangeKey])
|
||||
|
||||
|
||||
const modelSwitchRow = useMemo(() => {
|
||||
const mergeLabRow = useMemo(() => {
|
||||
const onMergeClicked = async () => {
|
||||
appState.serverSetting.mergeModel({
|
||||
command: "mix",
|
||||
defaultTrans: defaultTrans,
|
||||
files: mergeElements
|
||||
})
|
||||
}
|
||||
@ -89,15 +94,27 @@ export const MergeLabRow = (_props: MergeLabRowProps) => {
|
||||
<div className="body-row split-3-3-4 left-padding-1 guided">
|
||||
<div className="body-item-title left-padding-1">Model Merger</div>
|
||||
<div className="merge-field-container">
|
||||
{modelOptions.length == 0 ? <>no torch model or not same type</> : modelOptions}
|
||||
{modelOptions.length == 0 ? <>not PyTorch model or not same type</> : modelOptions}
|
||||
|
||||
<div className="merge-field">
|
||||
<div className="merge-field-elem grey-bold">Default Tune</div>
|
||||
<div className="merge-field-elem">
|
||||
<input type="range" className="body-item-input-slider-2nd" min="-50" max="50" step="1" value={defaultTrans} onChange={(e) => {
|
||||
setDefaultTrans(Number(e.target.value))
|
||||
}}></input>
|
||||
<span className="body-item-input-slider-val">{defaultTrans}</span>
|
||||
</div>
|
||||
</div >
|
||||
|
||||
|
||||
</div>
|
||||
<div className="body-button-container">
|
||||
<div className="body-button" onClick={onMergeClicked}>merge</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}, [mergeElements, appState.serverSetting.serverSetting])
|
||||
}, [mergeElements, appState.serverSetting.serverSetting, defaultTrans])
|
||||
|
||||
return modelSwitchRow
|
||||
}
|
||||
return mergeLabRow
|
||||
|
||||
}
|
@ -558,6 +558,10 @@ body {
|
||||
.body-item-input-slider-val {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
.body-item-input-slider-2nd {
|
||||
width: 60%;
|
||||
accent-color: #33f;
|
||||
}
|
||||
|
||||
.body-button-container {
|
||||
display: flex;
|
||||
@ -781,5 +785,15 @@ body {
|
||||
padding-left: 5px;
|
||||
width: 100%;
|
||||
}
|
||||
.red {
|
||||
color: #f00;
|
||||
}
|
||||
.purple {
|
||||
color: #33f;
|
||||
}
|
||||
.grey-bold {
|
||||
color: #555;
|
||||
font-weight: 800;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
client/lib/package-lock.json
generated
4
client/lib/package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@dannadori/voice-changer-client-js",
|
||||
"version": "1.0.119",
|
||||
"version": "1.0.120",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@dannadori/voice-changer-client-js",
|
||||
"version": "1.0.119",
|
||||
"version": "1.0.120",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@types/readable-stream": "^2.3.15",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@dannadori/voice-changer-client-js",
|
||||
"version": "1.0.119",
|
||||
"version": "1.0.120",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"directories": {
|
||||
|
@ -414,5 +414,6 @@ export type MergeElement = {
|
||||
}
|
||||
export type MergeModelRequest = {
|
||||
command: "mix",
|
||||
defaultTrans: number,
|
||||
files: MergeElement[]
|
||||
}
|
||||
|
@ -59,4 +59,7 @@ def merge_model(request: MergeModelRequest):
|
||||
merged["sr"] = state_dict["sr"]
|
||||
merged["f0"] = state_dict["f0"]
|
||||
merged["info"] = state_dict["info"]
|
||||
merged["embedder_name"] = (
|
||||
state_dict["embedder_name"] if "embedder_name" in state_dict else None
|
||||
)
|
||||
return merged
|
||||
|
@ -15,4 +15,5 @@ class MergeFile:
|
||||
class MergeModelRequest:
|
||||
command: str = ""
|
||||
slot: int = -1
|
||||
defaultTrans: int = 0
|
||||
files: List[MergeFile] = field(default_factory=lambda: [])
|
||||
|
@ -620,10 +620,14 @@ class RVC:
|
||||
indexFilename=None,
|
||||
clusterTorchModelFilename=None,
|
||||
)
|
||||
params = {
|
||||
"trans":req.defaultTrans
|
||||
}
|
||||
props: LoadModelParams = LoadModelParams(
|
||||
slot=targetSlot, isHalf=True, files=filePaths, params="{}"
|
||||
slot=targetSlot, isHalf=True, files=filePaths, params=json.dumps(params)
|
||||
)
|
||||
self.loadModel(props)
|
||||
self.prepareModel(targetSlot)
|
||||
self.settings.modelSlotIndex = targetSlot
|
||||
self.currentSlot = self.settings.modelSlotIndex
|
||||
# self.settings.tran = req.defaultTrans
|
||||
|
Loading…
Reference in New Issue
Block a user