AI 生成: 一个基于 AI 的全自动短视频生成工具,输入主题即可自动生成脚本、配音、字幕和合成视频。使用 Python + Flask 提供 Web 界面,支持命令行模式。
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
const btn = document.getElementById('btn');
|
||||
const statusEl = document.getElementById('status');
|
||||
const resultEl = document.getElementById('result');
|
||||
const videoEl = document.getElementById('video');
|
||||
const downloadEl = document.getElementById('download');
|
||||
const scriptEl = document.getElementById('script');
|
||||
|
||||
btn.addEventListener('click', async () => {
|
||||
const topic = document.getElementById('topic').value.trim();
|
||||
const scenes = parseInt(document.getElementById('scenes').value, 10) || 5;
|
||||
const rate = parseInt(document.getElementById('rate').value, 10) || 160;
|
||||
|
||||
if (!topic) {
|
||||
statusEl.textContent = '请填写主题';
|
||||
return;
|
||||
}
|
||||
|
||||
btn.disabled = true;
|
||||
resultEl.classList.add('hidden');
|
||||
statusEl.textContent = '生成中,请稍候(可能需要 1-3 分钟)...';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/generate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ topic, scenes, rate }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!data.ok) throw new Error(data.error || '生成失败');
|
||||
|
||||
statusEl.textContent = '完成!';
|
||||
videoEl.src = '/' + data.video;
|
||||
downloadEl.href = '/' + data.video;
|
||||
scriptEl.innerHTML = '';
|
||||
data.script.forEach((s) => {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = s.text;
|
||||
scriptEl.appendChild(li);
|
||||
});
|
||||
resultEl.classList.remove('hidden');
|
||||
} catch (e) {
|
||||
statusEl.textContent = '错误:' + e.message;
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
background: linear-gradient(135deg, #1e1e2f 0%, #2a2a4a 100%);
|
||||
color: #eaeaea;
|
||||
min-height: 100vh;
|
||||
}
|
||||
.container {
|
||||
max-width: 720px;
|
||||
margin: 40px auto;
|
||||
padding: 32px;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
h1 { margin-top: 0; font-size: 24px; }
|
||||
.sub { color: #aaa; margin-bottom: 24px; }
|
||||
.form { display: flex; flex-direction: column; gap: 8px; }
|
||||
.form label { font-size: 14px; color: #bbb; }
|
||||
.form input {
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #444;
|
||||
background: #1a1a2a;
|
||||
color: #eee;
|
||||
font-size: 14px;
|
||||
}
|
||||
.form button {
|
||||
margin-top: 12px;
|
||||
padding: 12px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(90deg, #6a5acd, #8a2be2);
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
.form button:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
.status { margin-top: 20px; color: #8fd3ff; min-height: 20px; }
|
||||
.result { margin-top: 24px; }
|
||||
.result video { width: 100%; border-radius: 12px; background: #000; }
|
||||
.result a { color: #8fd3ff; }
|
||||
.hidden { display: none; }
|
||||
Reference in New Issue
Block a user