Merge pull request #540 from pipecat-ai/cb/interruption-fix

Fixed RTVI `tts:interrupt` action not interrupting
This commit is contained in:
Aleix Conchillo Flaqué
2024-10-02 13:46:52 -07:00
committed by GitHub

View File

@@ -5,17 +5,17 @@
# #
import asyncio import asyncio
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from loguru import logger
from pipecat.frames.frames import ( from pipecat.frames.frames import (
BotInterruptionFrame, BotInterruptionFrame,
CancelFrame, CancelFrame,
InputAudioRawFrame,
StartFrame,
EndFrame, EndFrame,
Frame, Frame,
InputAudioRawFrame,
StartFrame,
StartInterruptionFrame, StartInterruptionFrame,
StopInterruptionFrame, StopInterruptionFrame,
SystemFrame, SystemFrame,
@@ -23,11 +23,10 @@ from pipecat.frames.frames import (
UserStoppedSpeakingFrame, UserStoppedSpeakingFrame,
VADParamsUpdateFrame, VADParamsUpdateFrame,
) )
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.transports.base_transport import TransportParams from pipecat.transports.base_transport import TransportParams
from pipecat.vad.vad_analyzer import VADAnalyzer, VADState from pipecat.vad.vad_analyzer import VADAnalyzer, VADState
from loguru import logger
class BaseInputTransport(FrameProcessor): class BaseInputTransport(FrameProcessor):
def __init__(self, params: TransportParams, **kwargs): def __init__(self, params: TransportParams, **kwargs):
@@ -87,6 +86,7 @@ class BaseInputTransport(FrameProcessor):
elif isinstance(frame, BotInterruptionFrame): elif isinstance(frame, BotInterruptionFrame):
logger.debug("Bot interruption") logger.debug("Bot interruption")
await self._start_interruption() await self._start_interruption()
await self.push_frame(StartInterruptionFrame())
# All other system frames # All other system frames
elif isinstance(frame, SystemFrame): elif isinstance(frame, SystemFrame):
await self.push_frame(frame, direction) await self.push_frame(frame, direction)