mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-23 07:51:18 +01:00
Added RVC upload functionality, allow to send rvc model archive (zip/7z format) to extras, automatically installed properly on server side.
This commit is contained in:
parent
7151b4dba8
commit
58123f5c29
@ -174,6 +174,30 @@ async function onDeleteClick() {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onClickUpload() {
|
||||||
|
const url = new URL(getApiUrl());
|
||||||
|
const inputFiles = $("#rvc_model_upload_file").get(0).files;
|
||||||
|
let formData = new FormData();
|
||||||
|
|
||||||
|
for(const file of inputFiles)
|
||||||
|
formData.append(file.name, file);
|
||||||
|
|
||||||
|
console.debug(DEBUG_PREFIX,"Sending files:",formData);
|
||||||
|
url.pathname = '/api/voice-conversion/rvc/upload-models';
|
||||||
|
|
||||||
|
const apiResult = await doExtrasFetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!apiResult.ok) {
|
||||||
|
toastr.error(apiResult.statusText, DEBUG_PREFIX+' Check extras console for errors log');
|
||||||
|
throw new Error(`HTTP ${apiResult.status}: ${await apiResult.text()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
alert('The file has been uploaded successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
function addExtensionControls() {
|
function addExtensionControls() {
|
||||||
const settingsHtml = `
|
const settingsHtml = `
|
||||||
@ -202,6 +226,15 @@ $(document).ready(function () {
|
|||||||
<select id="rvc_model_select">
|
<select id="rvc_model_select">
|
||||||
<!-- Populated by JS -->
|
<!-- Populated by JS -->
|
||||||
</select>
|
</select>
|
||||||
|
<div>
|
||||||
|
<label for="rvc_model_upload_file">Select models to upload (zip files)</label>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
id="rvc_model_upload_file"
|
||||||
|
accept=".zip,.rar,.7zip,.7z" multiple />
|
||||||
|
<button id="rvc_model_upload_button"> Upload </button>
|
||||||
|
<button id="rvc_model_refresh_button"> Refresh Voices </button>
|
||||||
|
</div>
|
||||||
<span>Select Pitch Extraction</span> </br>
|
<span>Select Pitch Extraction</span> </br>
|
||||||
<select id="rvc_pitch_extraction">
|
<select id="rvc_pitch_extraction">
|
||||||
<option value="dio">dio</option>
|
<option value="dio">dio</option>
|
||||||
@ -251,6 +284,10 @@ $(document).ready(function () {
|
|||||||
$("#rvc_apply").on("click", onApplyClick);
|
$("#rvc_apply").on("click", onApplyClick);
|
||||||
$("#rvc_delete").on("click", onDeleteClick);
|
$("#rvc_delete").on("click", onDeleteClick);
|
||||||
|
|
||||||
|
$("#rvc_model_upload_file").show();
|
||||||
|
$("#rvc_model_upload_button").on("click", onClickUpload);
|
||||||
|
$("#rvc_model_refresh_button").on("click", refreshVoiceList);
|
||||||
|
|
||||||
}
|
}
|
||||||
addExtensionControls(); // No init dependencies
|
addExtensionControls(); // No init dependencies
|
||||||
loadSettings(); // Depends on Extension Controls
|
loadSettings(); // Depends on Extension Controls
|
||||||
@ -338,10 +375,7 @@ async function rvcVoiceConversion(response, character) {
|
|||||||
// Module Worker //
|
// Module Worker //
|
||||||
//#############################//
|
//#############################//
|
||||||
|
|
||||||
async function moduleWorker() {
|
async function refreshVoiceList() {
|
||||||
updateCharactersList();
|
|
||||||
|
|
||||||
if (modules.includes('rvc') && !rvcModelsReceived) {
|
|
||||||
let result = await get_models_list();
|
let result = await get_models_list();
|
||||||
result = await result.json();
|
result = await result.json();
|
||||||
rvcModelsList = result["models_list"]
|
rvcModelsList = result["models_list"]
|
||||||
@ -359,6 +393,13 @@ async function moduleWorker() {
|
|||||||
|
|
||||||
rvcModelsReceived = true
|
rvcModelsReceived = true
|
||||||
console.debug(DEBUG_PREFIX,"Updated model list to:", rvcModelsList);
|
console.debug(DEBUG_PREFIX,"Updated model list to:", rvcModelsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function moduleWorker() {
|
||||||
|
updateCharactersList();
|
||||||
|
|
||||||
|
if (modules.includes('rvc') && !rvcModelsReceived) {
|
||||||
|
refreshVoiceList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user