feat: migrate TTS generation to frontend to utilize local browser proxy
This commit is contained in:
@@ -2464,6 +2464,25 @@ async function generateTtsWavToTemp(text, reference_id, model = DEFAULT_TTS_MODE
|
||||
return { tempName, tempPath, url: `/uploads/${tempName}` };
|
||||
}
|
||||
|
||||
app.post('/api/tts/upload_temp', upload.single('audio'), (req, res) => {
|
||||
try {
|
||||
if (!req.file) return res.status(400).json({ success: false, message: 'No audio file uploaded' });
|
||||
|
||||
const tempName = `temp_${Date.now()}_${Math.floor(Math.random() * 1000)}.wav`;
|
||||
const tempPath = path.join(uploadDir, tempName);
|
||||
|
||||
fs.renameSync(req.file.path, tempPath);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
tempName: tempName,
|
||||
url: `/uploads/${tempName}`
|
||||
});
|
||||
} catch (e) {
|
||||
res.status(500).json({ success: false, message: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/tts/generate', express.json(), async (req, res) => {
|
||||
const text = String(req.body?.text || '').trim();
|
||||
const reference_id = String(req.body?.reference_id || '').trim();
|
||||
|
||||
Reference in New Issue
Block a user