From 84143cc80c54dab66e953c4203b51d52700705fd Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Thu, 13 Feb 2025 07:00:44 -0500 Subject: [PATCH] self._muted now returns from STT process_audio_frames --- src/pipecat/services/ai_services.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pipecat/services/ai_services.py b/src/pipecat/services/ai_services.py index 50be621a4..b8d223176 100644 --- a/src/pipecat/services/ai_services.py +++ b/src/pipecat/services/ai_services.py @@ -525,9 +525,13 @@ class STTService(AIService): else: logger.warning(f"Unknown setting for STT service: {key}") - async def process_audio_frame(self, frame: AudioRawFrame): - if not self._muted: - await self.process_generator(self.run_stt(frame.audio)) + async def process_audio_frame(self, frame: AudioRawFrame, direction: FrameDirection): + if self._muted: + return + + await self.process_generator(self.run_stt(frame.audio)) + if self._audio_passthrough: + await self.push_frame(frame, direction) async def process_frame(self, frame: Frame, direction: FrameDirection): """Processes a frame of audio data, either buffering or transcribing it.""" @@ -537,9 +541,7 @@ class STTService(AIService): # In this service we accumulate audio internally and at the end we # push a TextFrame. We also push audio downstream in case someone # else needs it. - await self.process_audio_frame(frame) - if self._audio_passthrough: - await self.push_frame(frame, direction) + await self.process_audio_frame(frame, direction) elif isinstance(frame, STTUpdateSettingsFrame): await self._update_settings(frame.settings) elif isinstance(frame, STTMuteFrame):