Update TTS API to support asynchronous execution by replacing synchronous TTS calls with asynchronous counterparts in both api_v2.py and api_v3.py. Introduce new data classes in unified_engine.py for enhanced request handling and state management, improving overall system performance and maintainability.

This commit is contained in:
baicai-1145 2026-03-10 21:25:14 +08:00
parent d1a97fd04d
commit 6a427b4f54
3 changed files with 1607 additions and 222 deletions

File diff suppressed because it is too large Load Diff

View File

@ -221,7 +221,7 @@ async def tts_handle(req: dict):
"""
try:
result = tts_engine.run_direct_tts(req)
result = await tts_engine.run_direct_tts_async(req)
if result.streaming:
return StreamingResponse(result.audio_generator, media_type=f"audio/{result.media_type}")
return Response(result.audio_bytes, media_type=f"audio/{result.media_type}")

View File

@ -290,7 +290,7 @@ async def tts_handle(req: dict):
"""
try:
result = tts_engine.run_direct_tts(req)
result = await tts_engine.run_direct_tts_async(req)
if result.streaming:
return StreamingResponse(result.audio_generator, media_type=f"audio/{result.media_type}")
return Response(result.audio_bytes, media_type=f"audio/{result.media_type}")