Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

change upload btn style

chenxueshuang9dc79deaba5a
diff --git a/static/index.html b/static/index.html
index a11465a5..14081b0f 100644
--- a/static/index.html
+++ b/static/index.html
@@ -166,6 +166,23 @@
.formGroup input[type="checkbox"] {
margin-right: 10px;
}
+ .formGroup .voice-file-input {
+ width: auto;
+ min-width: 100px;
+ padding: 6px 10px;
+ text-align: center;
+ font-size: 12px;
+ border: 1px solid #999;
+ border-radius: 4px;
+ background: #eee;
+ cursor: pointer;
+ }
+ .formGroup .voice-file-input-remove {
+ display: none;
+ font-size: 12px;
+ color: #666;
+ cursor: pointer;
+ }
.loading {
word-break: keep-all;
color: #4caf50;
@@ -298,7 +315,11 @@
<option value="1">女声</option>
</select>
<span>或</span>
- <input type="file" id="voiceFileInput" name="voiceFileInput" accept="audio/*">
+ <label for="voiceFileInput" id="voiceFileInputName" class="voice-file-input">
+ 选择音色克隆样本
+ </label>
+ <span class="voice-file-input-remove" id="voiceFileInputRemove">删除</span>
+ <input style="display: none" type="file" id="voiceFileInput" name="voiceFileInput" accept="audio/*">
<p id="voiceUploadStatus" class="loading hidden">正在上传...</p>
</div>
@@ -342,6 +363,8 @@
const fileInput = document.getElementById('fileInput');
const uploadStatus = document.getElementById('uploadStatus');
const voiceFileInput = document.getElementById('voiceFileInput');
+ const voiceFileInputName = document.getElementById('voiceFileInputName');
+ const voiceFileInputRemove = document.getElementById('voiceFileInputRemove');
const voiceUploadStatus = document.getElementById('voiceUploadStatus');
const executeButton = document.getElementById('executeButton');
const taskForm = document.getElementById('taskForm');
@@ -365,6 +388,7 @@
const API_UPLOAD_URL = "/api/file";
let uploadedVideoUrl = null; // 存储上传后的视频地址
+ let uploadedAudioUrl = null; // 存储上传后的音频地址
// 更新状态(启用或禁用表单项)
function updateFormState() {
@@ -379,6 +403,7 @@
bilingualPosition.disabled = !bilingualToggle.checked;
voiceoverVoice.disabled = !voiceoverToggle.checked;
voiceFileInput.disabled = !voiceoverToggle.checked;
+ voiceFileInputName.style.cursor = voiceoverToggle.checked ? "pointer" : "not-allowed";
wordReplacementContainer.style.display = wordReplacementToggle.checked ? "block" : "none";
}
@@ -419,6 +444,14 @@
});
});
+ // 删除上传音频
+ voiceFileInputRemove.addEventListener("click", () => {
+ voiceFileInput.value = '';
+ voiceFileInputName.textContent = '选择音色克隆样本';
+ uploadedAudioUrl = null;
+ voiceFileInputRemove.style.display = 'none';
+ });
+
// 提交表单
function getParams () {
const formData = {
@@ -529,6 +562,8 @@
if (!response.ok) throw new Error('上传失败');
const data = await response.json();
uploadedAudioUrl = data.data.file_path; // 获取返回的地址
+ voiceFileInputName.textContent = file.name;
+ voiceFileInputRemove.style.display = 'block';
} catch (error) {
console.error('视频上传失败:', error);
alert('视频上传失败,请重试');