feat: API文档、文本自动分段、音色配置、批量并发

- 新增 API.md 完整接口文档
- 智能文本分段:长文本按段落/句子/标点边界自动切分(≤2000字/段),逐段TTS后ffmpeg拼接
- /api/tts 支持 voice 参数指定音色
- httpTts JSON 配置增加 style 和 voice 字段
- 批量生成改用并发(Semaphore 3路)
- 新增 /health 健康检查端点
- TTS 试听前端增加音色输入
- 清理 import,修复端口不一致
This commit is contained in:
sunruiling
2026-03-27 14:37:43 +08:00
parent 82624afe68
commit 30544f7f42
6 changed files with 680 additions and 47 deletions

View File

@@ -113,9 +113,15 @@ audio{width:100%;margin-top:8px}
<div id="tab-preview" class="tab-panel">
<div class="card">
<div class="card-title">🎙️ TTS 试听</div>
<div class="form-group">
<label>说话风格(可选)</label>
<input id="preview-style" placeholder="如:开心、语速慢、东北话、像个大将军...">
<div class="form-row">
<div class="form-group">
<label>说话风格(可选)</label>
<input id="preview-style" placeholder="如:开心、语速慢、东北话、像个大将军...">
</div>
<div class="form-group">
<label>音色(可选)</label>
<input id="preview-voice" placeholder="留空使用默认音色 mimo_default">
</div>
</div>
<div class="form-group">
<label>文本内容</label>
@@ -435,6 +441,7 @@ async function generateAll() {
async function doPreview() {
const text = document.getElementById('preview-text').value.trim();
const style = document.getElementById('preview-style').value.trim();
const voice = document.getElementById('preview-voice').value.trim();
if (!text) { toast('请输入文本', 'error'); return; }
const btn = document.getElementById('preview-btn');
btn.disabled = true;
@@ -443,7 +450,7 @@ async function doPreview() {
const res = await fetch('/admin/api/tts/preview', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({text, style})
body: JSON.stringify({text, style, voice})
});
const data = await res.json();
if (data.ok) {