Skip to content

Commit

Permalink
rtvi: reset bot transcription with interruptions
Browse files Browse the repository at this point in the history
  • Loading branch information
aconchillo committed Oct 15, 2024
1 parent f0d89e5 commit 4a71eac
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/pipecat/processors/frameworks/rtvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,18 @@ async def process_frame(self, frame: Frame, direction: FrameDirection):

await self.push_frame(frame, direction)

if isinstance(frame, TextFrame):
if isinstance(frame, UserStartedSpeakingFrame):
await self._push_aggregation()
elif isinstance(frame, TextFrame):
self._aggregation += frame.text
if match_endofsentence(self._aggregation):
message = RTVIBotTranscriptionMessage(
data=RTVITextMessageData(text=self._aggregation)
)
await self._push_transport_message_urgent(message)
self._aggregation = ""
await self._push_aggregation()

async def _push_aggregation(self):
if len(self._aggregation) > 0:
message = RTVIBotTranscriptionMessage(data=RTVITextMessageData(text=self._aggregation))
await self._push_transport_message_urgent(message)
self._aggregation = ""


class RTVIBotLLMProcessor(RTVIFrameProcessor):
Expand Down

0 comments on commit 4a71eac

Please sign in to comment.