diff --git a/backend/app/services/fish_audio_service.py b/backend/app/services/fish_audio_service.py index 5bde26d..f97a821 100644 --- a/backend/app/services/fish_audio_service.py +++ b/backend/app/services/fish_audio_service.py @@ -2,6 +2,11 @@ import os import requests +PROXY_URL = 'http://202.182.125.133:8443/fish-api/v1/tts' +PROXY_USER = 'fishproxy' +PROXY_PASS = 'AO7C6SiovkRydkSHsUPJaOZw0CBh9mp0' + + def synthesize_fish_audio(text, speed=1.0, pitch=0, volume=1.0, emotion='neutral'): api_key = os.getenv('FISH_AUDIO_API_KEY', '') if not api_key: @@ -20,9 +25,8 @@ def synthesize_fish_audio(text, speed=1.0, pitch=0, volume=1.0, emotion='neutral if tag: text = f"{tag}{text}" - url = 'https://api.fish.audio/v1/tts' headers = { - 'Authorization': f'Bearer {api_key}', + 'X-Fish-Auth': f'Bearer {api_key}', 'Content-Type': 'application/json' } @@ -34,7 +38,10 @@ def synthesize_fish_audio(text, speed=1.0, pitch=0, volume=1.0, emotion='neutral 'volume': max(-20, min(20, (volume - 1.0) * 20)), } - response = requests.post(url, json=payload, headers=headers, timeout=60, stream=True) + response = requests.post( + PROXY_URL, json=payload, headers=headers, + auth=(PROXY_USER, PROXY_PASS), timeout=120 + ) if response.status_code != 200: raise Exception(f'Fish Audio API错误: {response.status_code} - {response.text[:200]}')