Revert TTS generation to backend with fixed local proxy 127.0.0.1:7890

This commit is contained in:
2026-08-01 18:25:50 +08:00
parent c76538e4bd
commit 2741b2d321
3 changed files with 26 additions and 66 deletions
+8 -8
View File
@@ -2423,7 +2423,7 @@ function requestDirect(urlStr, options) {
async function generateTtsWavToTemp(text, reference_id, model = DEFAULT_TTS_MODEL) {
let 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;
if (!proxyUrl && os.platform() === 'win32') {
if (!proxyUrl) {
proxyUrl = 'http://127.0.0.1:7890';
}
@@ -2512,21 +2512,21 @@ app.post('/api/tts/generate', express.json(), async (req, res) => {
body: requestBody
};
// Always try to use local proxy first if we are on a Windows machine
if (!proxyUrl && os.platform() === 'win32') {
// Always try to use proxy
if (!proxyUrl) {
proxyUrl = 'http://127.0.0.1:7890';
}
let response;
try {
response = proxyUrl
? await requestViaProxy('https://fishaudio.fse-media.group/v1/tts', options, proxyUrl)
: await requestDirect('https://fishaudio.fse-media.group/v1/tts', options);
? await requestViaProxy('https://api.fish.audio/v1/tts', options, proxyUrl)
: await requestDirect('https://api.fish.audio/v1/tts', options);
} catch (e) {
// Fallback for Windows if local proxy fails
if (os.platform() === 'win32' && proxyUrl === 'http://127.0.0.1:7890') {
// Fallback if proxy fails
if (proxyUrl === 'http://127.0.0.1:7890') {
console.log(`[TTS] Local proxy failed, attempting direct connection...`);
response = await requestDirect('https://fishaudio.fse-media.group/v1/tts', options);
response = await requestDirect('https://api.fish.audio/v1/tts', options);
} else {
throw e;
}