diff --git a/__pycache__/tts_service.cpython-310.pyc b/__pycache__/tts_service.cpython-310.pyc index 81dcc0d..998696a 100644 Binary files a/__pycache__/tts_service.cpython-310.pyc and b/__pycache__/tts_service.cpython-310.pyc differ diff --git a/logs/server.log b/logs/server.log index 6d7db33..e02f463 100644 Binary files a/logs/server.log and b/logs/server.log differ diff --git a/requirements.txt b/requirements.txt index 7c99566..015d625 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ fastapi==0.110.0 uvicorn==0.27.1 python-multipart==0.0.9 aiohttp==3.9.3 -edge-tts==6.1.9 \ No newline at end of file +edge-tts==6.1.9 +requests==2.31.0 \ No newline at end of file diff --git a/tts_service.py b/tts_service.py index c01aa66..b104d1f 100644 --- a/tts_service.py +++ b/tts_service.py @@ -145,24 +145,13 @@ class ChatTTSProvider(TTSProvider): """检查 ChatTTS 是否可用""" if self._available is None: try: - import aiohttp - import asyncio - - async def check(): - try: - async with aiohttp.ClientSession() as session: - async with session.get( - f"{self.CHATTTS_URL}/health", - timeout=aiohttp.ClientTimeout(total=5) - ) as resp: - if resp.status == 200: - data = await resp.json() - return data.get("status") == "ok" - except: - pass - return False - - self._available = asyncio.get_event_loop().run_until_complete(check()) + import requests + resp = requests.get(f"{self.CHATTTS_URL}/health", timeout=5) + if resp.status_code == 200: + data = resp.json() + self._available = data.get("status") == "ok" + else: + self._available = False except Exception as e: logger.warning(f"ChatTTS check failed: {e}") self._available = False