feat(tts): switch broadcast generation to s2.1-pro-free
Update the generator and temp broadcast flows to send the new Fish Audio model and reference IDs so Chinese and secondary-language audio use the latest requested voice configuration.
This commit is contained in:
@@ -719,8 +719,9 @@
|
||||
<div class="toast-container" id="toast-container"></div>
|
||||
|
||||
<script>
|
||||
const ZH_MODEL = "7b64d954530d490a8c40827e618e55c6";
|
||||
const EN_MODEL = "fe09163b345448eabfeccb25dc435c43";
|
||||
const TTS_MODEL = "s2.1-pro-free";
|
||||
const ZH_REFERENCE_ID = "0aee9f0f5683480d987c9e3c5d2de04c";
|
||||
const EN_REFERENCE_ID = "38985e545cff41b79c11c32b0196c9a0";
|
||||
|
||||
let zhTempFile = null;
|
||||
let enTempFile = null;
|
||||
@@ -821,7 +822,7 @@
|
||||
const res = await fetch('/api/tts/generate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ text, reference_id })
|
||||
body: JSON.stringify({ text, reference_id, model: TTS_MODEL })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!data.success) throw new Error(data.message);
|
||||
@@ -1110,7 +1111,8 @@
|
||||
},
|
||||
body: JSON.stringify({
|
||||
text: zhText,
|
||||
reference_id: ZH_MODEL
|
||||
reference_id: ZH_REFERENCE_ID,
|
||||
model: TTS_MODEL
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1127,7 +1129,8 @@
|
||||
},
|
||||
body: JSON.stringify({
|
||||
text: enText,
|
||||
reference_id: EN_MODEL
|
||||
reference_id: EN_REFERENCE_ID,
|
||||
model: TTS_MODEL
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -235,7 +235,8 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const ZH_MODEL = "7b64d954530d490a8c40827e618e55c6";
|
||||
const TTS_MODEL = "s2.1-pro-free";
|
||||
const ZH_REFERENCE_ID = "0aee9f0f5683480d987c9e3c5d2de04c";
|
||||
let state = {
|
||||
broadcastId: null,
|
||||
broadcastUrl: null
|
||||
@@ -335,7 +336,12 @@
|
||||
const resp = await fetch("/api/temp-broadcast/compose", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ text, reference_id: ZH_MODEL, prefixName: "lsts" })
|
||||
body: JSON.stringify({
|
||||
text,
|
||||
reference_id: ZH_REFERENCE_ID,
|
||||
model: TTS_MODEL,
|
||||
prefixName: "lsts"
|
||||
})
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (!data || !data.success) throw new Error(data?.message || "合成失败");
|
||||
|
||||
+15
-6
@@ -16,7 +16,9 @@ const server = http.createServer(app);
|
||||
const wss = new WebSocket.Server({ server });
|
||||
|
||||
const PORT = Number(process.env.PORT || '8999');
|
||||
const DEFAULT_ZH_MODEL = process.env.ZH_MODEL || '7b64d954530d490a8c40827e618e55c6';
|
||||
const DEFAULT_TTS_MODEL = process.env.TTS_MODEL || 's2.1-pro-free';
|
||||
const DEFAULT_ZH_REFERENCE_ID = process.env.ZH_REFERENCE_ID || '0aee9f0f5683480d987c9e3c5d2de04c';
|
||||
const DEFAULT_EN_REFERENCE_ID = process.env.EN_REFERENCE_ID || '38985e545cff41b79c11c32b0196c9a0';
|
||||
|
||||
const HLS_ENABLE = process.env.HLS_ENABLE !== '0';
|
||||
const HLS_STREAM_MODE = (process.env.HLS_STREAM_MODE || 'event').toLowerCase();
|
||||
@@ -2265,12 +2267,13 @@ function requestDirect(urlStr, options) {
|
||||
});
|
||||
}
|
||||
|
||||
async function generateTtsWavToTemp(text, reference_id) {
|
||||
async function generateTtsWavToTemp(text, reference_id, model = DEFAULT_TTS_MODEL) {
|
||||
const proxyUrl = process.env.HTTP_PROXY || process.env.http_proxy || process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy;
|
||||
|
||||
const requestBody = JSON.stringify({
|
||||
text: text,
|
||||
reference_id: reference_id,
|
||||
model: model,
|
||||
format: "wav"
|
||||
});
|
||||
|
||||
@@ -2305,16 +2308,20 @@ async function generateTtsWavToTemp(text, reference_id) {
|
||||
}
|
||||
|
||||
app.post('/api/tts/generate', express.json(), async (req, res) => {
|
||||
const { text, reference_id } = req.body;
|
||||
const text = String(req.body?.text || '').trim();
|
||||
const reference_id = String(req.body?.reference_id || '').trim();
|
||||
const model = String(req.body?.model || DEFAULT_TTS_MODEL).trim();
|
||||
if (!text || !reference_id) return res.status(400).json({ success: false, message: 'Missing text or reference_id' });
|
||||
if (!model) return res.status(400).json({ success: false, message: 'Missing model' });
|
||||
|
||||
try {
|
||||
const proxyUrl = process.env.HTTP_PROXY || process.env.http_proxy || process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy;
|
||||
console.log(`[TTS] Sending request for text: "${text}"${proxyUrl ? ` via proxy: ${proxyUrl}` : ''}`);
|
||||
console.log(`[TTS] Sending request for text: "${text}" with model "${model}"${proxyUrl ? ` via proxy: ${proxyUrl}` : ''}`);
|
||||
|
||||
const requestBody = JSON.stringify({
|
||||
text: text,
|
||||
reference_id: reference_id,
|
||||
model: model,
|
||||
format: "wav"
|
||||
});
|
||||
|
||||
@@ -2482,17 +2489,19 @@ app.post('/api/temp-broadcast/build', (req, res) => {
|
||||
|
||||
app.post('/api/temp-broadcast/compose', express.json(), async (req, res) => {
|
||||
const text = String(req.body?.text || '').trim();
|
||||
const reference_id = String(req.body?.reference_id || DEFAULT_ZH_MODEL).trim();
|
||||
const reference_id = String(req.body?.reference_id || DEFAULT_ZH_REFERENCE_ID).trim();
|
||||
const model = String(req.body?.model || DEFAULT_TTS_MODEL).trim();
|
||||
const prefixName = String(req.body?.prefixName || 'lsts').trim();
|
||||
if (!text) return res.status(400).json({ success: false, message: 'text required' });
|
||||
if (!reference_id) return res.status(400).json({ success: false, message: 'reference_id required' });
|
||||
if (!model) return res.status(400).json({ success: false, message: 'model required' });
|
||||
|
||||
const prefixWavPath = findWavByBaseName(prefixName);
|
||||
if (!prefixWavPath) return res.status(404).json({ success: false, message: `Prefix wav not found: ${prefixName}.wav` });
|
||||
|
||||
let ttsTempPath = null;
|
||||
try {
|
||||
const tts = await generateTtsWavToTemp(text, reference_id);
|
||||
const tts = await generateTtsWavToTemp(text, reference_id, model);
|
||||
ttsTempPath = tts.tempPath;
|
||||
const built = buildTempBroadcastFromWav(prefixWavPath, ttsTempPath);
|
||||
try { fs.unlinkSync(ttsTempPath); } catch {}
|
||||
|
||||
Reference in New Issue
Block a user