Handle cancellation, stopping, and restarting

This commit is contained in:
Sharvil Nanavati
2024-08-27 01:24:00 +00:00
parent 1d92fc3199
commit c979762b70
2 changed files with 36 additions and 14 deletions

View File

@@ -19,6 +19,7 @@ from pipecat.frames.frames import (
Frame,
AudioRawFrame,
StartFrame,
StartInterruptionFrame,
EndFrame,
TTSStartedFrame,
TTSStoppedFrame,
@@ -86,6 +87,11 @@ class LmntTTSService(TTSService):
await super().cancel(frame)
await self._disconnect()
async def push_frame(self, frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM):
await super().push_frame(frame, direction)
if isinstance(frame, (TTSStoppedFrame, StartInterruptionFrame)):
self._started = False
async def _connect(self):
try:
self._speech = Speech()