Skip to content

Commit

Permalink
fixes as noted by aleix
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindla committed Sep 25, 2024
1 parent a70a59f commit cb11b6f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pipecat/services/ai_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ async def run_tts(self, text: str) -> AsyncGenerator[Frame, None]:

async def say(self, text: str):
await self.process_frame(TextFrame(text=text), FrameDirection.DOWNSTREAM)
await self.flush_audio()

async def _handle_interruption(self, frame: StartInterruptionFrame, direction: FrameDirection):
self._current_sentence = ""
Expand Down Expand Up @@ -231,7 +230,6 @@ async def process_frame(self, frame: Frame, direction: FrameDirection):
await self.push_frame(frame, direction)
elif isinstance(frame, TTSSpeakFrame):
await self._push_tts_frames(frame.text)
await self.flush_audio()
elif isinstance(frame, TTSModelUpdateFrame):
await self.set_model(frame.model)
elif isinstance(frame, TTSVoiceUpdateFrame):
Expand Down Expand Up @@ -261,6 +259,10 @@ def __init__(
async def flush_audio(self):
pass

async def say(self, text: str):
await super.say(text)
await self.flush_audio()

async def start(self, frame: StartFrame):
await super().start(frame)
if self._push_stop_frames:
Expand All @@ -280,6 +282,11 @@ async def cancel(self, frame: CancelFrame):
await self._stop_frame_task
self._stop_frame_task = None

async def process_frame(self, frame: Frame, direction: FrameDirection):
super().process_frame(frame, direction)
if isinstance(frame, TTSSpeakFrame):
await self.flush_audio()

async def push_frame(self, frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM):
await super().push_frame(frame, direction)

Expand Down

0 comments on commit cb11b6f

Please sign in to comment.