From ef66d759515fcb7306b808961997ddec6f78871a Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:31:54 -0800 Subject: [PATCH] fix(speech): call Gemini once per TTS request aspeech re-ran speech whenever the first result was not a coroutine, so the speech-to-completion bridge sent every async Gemini and Vertex AI TTS request upstream twice. It now returns the sync result Prerequisite for the backport of #50803 to lts/1.108.x, whose tests count one upstream request per speech call. Hand-ported from f4347d4f50 (#44551, main), the aspeech hunk only. --- litellm/main.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index 035e0628d8c..0b35892824b 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -8430,14 +8430,8 @@ async def aspeech(*args, **kwargs) -> HttpxBinaryResponseContent: api_base=api_base_hint, ) - # Await normally init_response: Final = await loop.run_in_executor(None, func_with_context) - if asyncio.iscoroutine(init_response): - response = await init_response - else: - # Call the synchronous function using run_in_executor - response = await loop.run_in_executor(None, func_with_context) - return response + return await init_response if asyncio.iscoroutine(init_response) else init_response except Exception as e: custom_llm_provider = custom_llm_provider or "openai" raise exception_type(