diff --git a/client/demo/dist/index.js b/client/demo/dist/index.js index bdb1251f..14d5096b 100644 --- a/client/demo/dist/index.js +++ b/client/demo/dist/index.js @@ -235,7 +235,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MergeLabDialog: () => (/* binding */ MergeLabDialog)\n/* harmony export */ });\n/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ \"./node_modules/@babel/runtime/helpers/esm/slicedToArray.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _001_GuiStateProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./001_GuiStateProvider */ \"./src/components/demo/001_GuiStateProvider.tsx\");\n/* harmony import */ var _001_provider_001_AppStateProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../001_provider/001_AppStateProvider */ \"./src/001_provider/001_AppStateProvider.tsx\");\n/* harmony import */ var _dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @dannadori/voice-changer-client-js */ \"./node_modules/@dannadori/voice-changer-client-js/dist/index.js\");\n/* harmony import */ var _dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4__);\n\n\n\n\n\nvar MergeLabDialog = function MergeLabDialog() {\n var guiState = (0,_001_GuiStateProvider__WEBPACK_IMPORTED_MODULE_2__.useGuiState)();\n var _useAppState = (0,_001_provider_001_AppStateProvider__WEBPACK_IMPORTED_MODULE_3__.useAppState)(),\n serverSetting = _useAppState.serverSetting;\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(\"\"),\n _useState2 = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(_useState, 2),\n currentFilter = _useState2[0],\n setCurrentFilter = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)([]),\n _useState4 = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(_useState3, 2),\n mergeElements = _useState4[0],\n setMergeElements = _useState4[1];\n\n // スロットが変更されたときの初期化処理\n var newSlotChangeKey = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n if (!serverSetting.serverSetting.modelSlots) {\n return \"\";\n }\n return serverSetting.serverSetting.modelSlots.reduce(function (prev, cur) {\n return prev + \"_\" + cur.modelFile;\n }, \"\");\n }, [serverSetting.serverSetting.modelSlots]);\n var filterItems = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n return serverSetting.serverSetting.modelSlots.reduce(function (prev, cur) {\n if (cur.voiceChangerType != \"RVC\") {\n return prev;\n }\n var curRVC = cur;\n var key = \"\".concat(curRVC.modelType, \",\").concat(cur.samplingRate, \",\").concat(curRVC.embChannels);\n var val = {\n type: curRVC.modelType,\n samplingRate: cur.samplingRate,\n embChannels: curRVC.embChannels\n };\n var existKeys = Object.keys(prev);\n if (!cur.modelFile || cur.modelFile.length == 0) {\n return prev;\n }\n if (curRVC.modelType == \"onnxRVC\" || curRVC.modelType == \"onnxRVCNono\") {\n return prev;\n }\n if (!existKeys.includes(key)) {\n prev[key] = val;\n }\n return prev;\n }, {});\n }, [newSlotChangeKey]);\n var models = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n return serverSetting.serverSetting.modelSlots.filter(function (x) {\n if (x.voiceChangerType != \"RVC\") {\n return;\n }\n var xRVC = x;\n var filterVals = filterItems[currentFilter];\n if (!filterVals) {\n return false;\n }\n if (xRVC.modelType == filterVals.type && xRVC.samplingRate == filterVals.samplingRate && xRVC.embChannels == filterVals.embChannels) {\n return true;\n } else {\n return false;\n }\n });\n }, [filterItems, currentFilter]);\n (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {\n if (Object.keys(filterItems).length > 0) {\n setCurrentFilter(Object.keys(filterItems)[0]);\n }\n }, [filterItems]);\n (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {\n // models はフィルタ後の配列\n var newMergeElements = models.map(function (x) {\n return {\n slotIndex: x.slotIndex,\n filename: x.modelFile,\n strength: 0\n };\n });\n setMergeElements(newMergeElements);\n }, [models]);\n var dialog = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n var closeButtonRow = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-row split-3-4-3 left-padding-1\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-item-text\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-button-container body-button-container-space-around\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-button\",\n onClick: function onClick() {\n guiState.stateControls.showMergeLabCheckbox.updateState(false);\n }\n }, \"close\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-item-text\"\n }));\n var filterOptions = Object.keys(filterItems).map(function (x) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"option\", {\n key: x,\n value: x\n }, x);\n }).filter(function (x) {\n return x != null;\n });\n var onMergeElementsChanged = function onMergeElementsChanged(slotIndex, strength) {\n var newMergeElements = mergeElements.map(function (x) {\n if (x.slotIndex == slotIndex) {\n return {\n slotIndex: x.slotIndex,\n filename: x.filename,\n strength: strength\n };\n } else {\n return x;\n }\n });\n setMergeElements(newMergeElements);\n };\n var onMergeClicked = function onMergeClicked() {\n var validMergeElements = mergeElements.filter(function (x) {\n return x.strength > 0;\n });\n serverSetting.mergeModel({\n voiceChangerType: _dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4__.VoiceChangerType.RVC,\n command: \"mix\",\n files: validMergeElements\n });\n };\n var modelList = mergeElements.map(function (x, index) {\n var _models$find;\n var name = ((_models$find = models.find(function (model) {\n return model.slotIndex == x.slotIndex;\n })) === null || _models$find === void 0 ? void 0 : _models$find.name) || \"\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n key: index,\n className: \"merge-lab-model-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"input\", {\n type: \"range\",\n className: \"body-item-input-slider\",\n min: \"0\",\n max: \"100\",\n step: \"1\",\n value: x.strength,\n onChange: function onChange(e) {\n onMergeElementsChanged(x.slotIndex, Number(e.target.value));\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"span\", {\n className: \"body-item-input-slider-val\"\n }, x.strength)));\n });\n var content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-container\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-type-filter\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, \"Type:\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"select\", {\n value: currentFilter,\n onChange: function onChange(e) {\n setCurrentFilter(e.target.value);\n }\n }, filterOptions))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-manipulator\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-model-list\"\n }, modelList), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-merge-buttons\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-merge-buttons-notice\"\n }, \"The merged model is stored in the final slot. If you assign this slot, it will be overwritten.\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-merge-button\",\n onClick: onMergeClicked\n }, \"merge\"))));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"dialog-frame\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"dialog-title\"\n }, \"MergeLab\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"dialog-content\"\n }, content, closeButtonRow));\n }, [newSlotChangeKey, currentFilter, mergeElements, models]);\n return dialog;\n};\n\n//# sourceURL=webpack://demo/./src/components/demo/905_MergeLabDialog.tsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ MergeLabDialog: () => (/* binding */ MergeLabDialog)\n/* harmony export */ });\n/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ \"./node_modules/@babel/runtime/helpers/esm/slicedToArray.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _001_GuiStateProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./001_GuiStateProvider */ \"./src/components/demo/001_GuiStateProvider.tsx\");\n/* harmony import */ var _001_provider_001_AppStateProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../001_provider/001_AppStateProvider */ \"./src/001_provider/001_AppStateProvider.tsx\");\n/* harmony import */ var _dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @dannadori/voice-changer-client-js */ \"./node_modules/@dannadori/voice-changer-client-js/dist/index.js\");\n/* harmony import */ var _dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4__);\n\n\n\n\n\nvar MergeLabDialog = function MergeLabDialog() {\n var guiState = (0,_001_GuiStateProvider__WEBPACK_IMPORTED_MODULE_2__.useGuiState)();\n var _useAppState = (0,_001_provider_001_AppStateProvider__WEBPACK_IMPORTED_MODULE_3__.useAppState)(),\n serverSetting = _useAppState.serverSetting;\n var _useState = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(\"\"),\n _useState2 = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(_useState, 2),\n currentFilter = _useState2[0],\n setCurrentFilter = _useState2[1];\n var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)([]),\n _useState4 = (0,_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(_useState3, 2),\n mergeElements = _useState4[0],\n setMergeElements = _useState4[1];\n\n // スロットが変更されたときの初期化処理\n var newSlotChangeKey = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n if (!serverSetting.serverSetting.modelSlots) {\n return \"\";\n }\n return serverSetting.serverSetting.modelSlots.reduce(function (prev, cur) {\n return prev + \"_\" + cur.modelFile;\n }, \"\");\n }, [serverSetting.serverSetting.modelSlots]);\n var filterItems = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n return serverSetting.serverSetting.modelSlots.reduce(function (prev, cur) {\n if (cur.voiceChangerType != \"RVC\") {\n return prev;\n }\n var curRVC = cur;\n var key = \"\".concat(curRVC.modelType, \",\").concat(cur.samplingRate, \",\").concat(curRVC.embChannels);\n var val = {\n type: curRVC.modelType,\n samplingRate: cur.samplingRate,\n embChannels: curRVC.embChannels\n };\n var existKeys = Object.keys(prev);\n if (!cur.modelFile || cur.modelFile.length == 0) {\n return prev;\n }\n if (curRVC.modelType == \"onnxRVC\" || curRVC.modelType == \"onnxRVCNono\") {\n return prev;\n }\n if (!existKeys.includes(key)) {\n prev[key] = val;\n }\n return prev;\n }, {});\n }, [newSlotChangeKey]);\n var models = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n return serverSetting.serverSetting.modelSlots.filter(function (x) {\n if (x.voiceChangerType != \"RVC\") {\n return;\n }\n var xRVC = x;\n var filterVals = filterItems[currentFilter];\n if (!filterVals) {\n return false;\n }\n if (xRVC.modelType == filterVals.type && xRVC.samplingRate == filterVals.samplingRate && xRVC.embChannels == filterVals.embChannels) {\n return true;\n } else {\n return false;\n }\n });\n }, [filterItems, currentFilter]);\n (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {\n if (Object.keys(filterItems).length > 0) {\n setCurrentFilter(Object.keys(filterItems)[0]);\n }\n }, [filterItems]);\n (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {\n // models はフィルタ後の配列\n var newMergeElements = models.map(function (x) {\n return {\n slotIndex: x.slotIndex,\n filename: x.modelFile,\n strength: 0\n };\n });\n setMergeElements(newMergeElements);\n }, [models]);\n var dialog = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(function () {\n var closeButtonRow = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-row split-3-4-3 left-padding-1\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-item-text\"\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-button-container body-button-container-space-around\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-button\",\n onClick: function onClick() {\n guiState.stateControls.showMergeLabCheckbox.updateState(false);\n }\n }, \"close\")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"body-item-text\"\n }));\n var filterOptions = Object.keys(filterItems).map(function (x) {\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"option\", {\n key: x,\n value: x\n }, x);\n }).filter(function (x) {\n return x != null;\n });\n var onMergeElementsChanged = function onMergeElementsChanged(slotIndex, strength) {\n var newMergeElements = mergeElements.map(function (x) {\n if (x.slotIndex == slotIndex) {\n return {\n slotIndex: x.slotIndex,\n strength: strength\n };\n } else {\n return x;\n }\n });\n setMergeElements(newMergeElements);\n };\n var onMergeClicked = function onMergeClicked() {\n var validMergeElements = mergeElements.filter(function (x) {\n return x.strength > 0;\n });\n serverSetting.mergeModel({\n voiceChangerType: _dannadori_voice_changer_client_js__WEBPACK_IMPORTED_MODULE_4__.VoiceChangerType.RVC,\n command: \"mix\",\n files: validMergeElements\n });\n };\n var modelList = mergeElements.map(function (x, index) {\n var _models$find;\n var name = ((_models$find = models.find(function (model) {\n return model.slotIndex == x.slotIndex;\n })) === null || _models$find === void 0 ? void 0 : _models$find.name) || \"\";\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n key: index,\n className: \"merge-lab-model-item\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"input\", {\n type: \"range\",\n className: \"body-item-input-slider\",\n min: \"0\",\n max: \"100\",\n step: \"1\",\n value: x.strength,\n onChange: function onChange(e) {\n onMergeElementsChanged(x.slotIndex, Number(e.target.value));\n }\n }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"span\", {\n className: \"body-item-input-slider-val\"\n }, x.strength)));\n });\n var content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-container\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-type-filter\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, \"Type:\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"select\", {\n value: currentFilter,\n onChange: function onChange(e) {\n setCurrentFilter(e.target.value);\n }\n }, filterOptions))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-manipulator\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-model-list\"\n }, modelList), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-merge-buttons\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-merge-buttons-notice\"\n }, \"The merged model is stored in the final slot. If you assign this slot, it will be overwritten.\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"merge-lab-merge-button\",\n onClick: onMergeClicked\n }, \"merge\"))));\n return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"dialog-frame\"\n }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"dialog-title\"\n }, \"MergeLab\"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(\"div\", {\n className: \"dialog-content\"\n }, content, closeButtonRow));\n }, [newSlotChangeKey, currentFilter, mergeElements, models]);\n return dialog;\n};\n\n//# sourceURL=webpack://demo/./src/components/demo/905_MergeLabDialog.tsx?"); /***/ }), diff --git a/client/demo/src/components/demo/905_MergeLabDialog.tsx b/client/demo/src/components/demo/905_MergeLabDialog.tsx index 233b71bb..baaf3763 100644 --- a/client/demo/src/components/demo/905_MergeLabDialog.tsx +++ b/client/demo/src/components/demo/905_MergeLabDialog.tsx @@ -107,7 +107,7 @@ export const MergeLabDialog = () => { const onMergeElementsChanged = (slotIndex: number, strength: number) => { const newMergeElements = mergeElements.map((x) => { if (x.slotIndex == slotIndex) { - return { slotIndex: x.slotIndex, filename: x.filename, strength: strength }; + return { slotIndex: x.slotIndex, strength: strength }; } else { return x; } diff --git a/client/lib/src/const.ts b/client/lib/src/const.ts index 1e727462..19d8e383 100644 --- a/client/lib/src/const.ts +++ b/client/lib/src/const.ts @@ -540,7 +540,6 @@ export type OnnxExporterInfo = { // Merge export type MergeElement = { slotIndex: number - filename: string // 一意性は保障されない場合がある(フォルダコピーされたときとか) strength: number } export type MergeModelRequest = { diff --git a/server/voice_changer/utils/ModelMerger.py b/server/voice_changer/utils/ModelMerger.py index 9bec7726..fe9ad47a 100644 --- a/server/voice_changer/utils/ModelMerger.py +++ b/server/voice_changer/utils/ModelMerger.py @@ -6,7 +6,6 @@ from dataclasses import dataclass @dataclass class MergeElement: slotIndex: int - filename: str strength: int