From 14e5419913a6ddb410853796b671158ce72afc74 Mon Sep 17 00:00:00 2001 From: Mert Sefa AKGUN Date: Sun, 12 Jan 2025 22:16:47 +0300 Subject: [PATCH] fix(gemini): prevent non-audio modality processing Add an early return in the _handle_transcribe_model_audio method to prevent unnecessary processing when the modalities setting is not set to audio. This change ensures that audio transcription only occurs when appropriate. --- src/pipecat/services/gemini_multimodal_live/gemini.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pipecat/services/gemini_multimodal_live/gemini.py b/src/pipecat/services/gemini_multimodal_live/gemini.py index 82959e24f..d05ead71f 100644 --- a/src/pipecat/services/gemini_multimodal_live/gemini.py +++ b/src/pipecat/services/gemini_multimodal_live/gemini.py @@ -288,6 +288,10 @@ class GeminiMultimodalLiveLLMService(LLMService): ) async def _handle_transcribe_model_audio(self, audio, context): + # Early return if modalities are not set to audio. + if self._settings["modalities"] != GeminiMultimodalModalities.AUDIO: + return + text = await self._transcribe_audio(audio, context) logger.debug(f"[Transcription:model] {text}") # We add user messages directly to the context. We don't do that for assistant messages,