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:
+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