Merge pull request #1029 from Vaibhav159/vl_fixing_idle_frame_processor_logic

fixing IdleFrameProcessor and UserIdleProcessor init logic
This commit is contained in:
Aleix Conchillo Flaqué
2025-01-17 06:48:13 -08:00
committed by GitHub
3 changed files with 11 additions and 5 deletions

View File

@@ -95,6 +95,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed an issue where setting the voice and model for `RimeHttpTTSService`
wasn't working.
- Fixed an issue where `IdleFrameProcessor` and `UserIdleProcessor` were getting
initialized before the start of the pipeline.
## [0.0.52] - 2024-12-24
### Added

View File

@@ -7,7 +7,7 @@
import asyncio
from typing import Awaitable, Callable, List
from pipecat.frames.frames import Frame
from pipecat.frames.frames import Frame, StartFrame
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
@@ -31,11 +31,12 @@ class IdleFrameProcessor(FrameProcessor):
self._timeout = timeout
self._types = types
self._create_idle_task()
async def process_frame(self, frame: Frame, direction: FrameDirection):
await super().process_frame(frame, direction)
if isinstance(frame, StartFrame):
self._create_idle_task()
await self.push_frame(frame, direction)
# If we are not waiting for any specific frame set the event, otherwise

View File

@@ -12,6 +12,7 @@ from pipecat.frames.frames import (
CancelFrame,
EndFrame,
Frame,
StartFrame,
UserStartedSpeakingFrame,
UserStoppedSpeakingFrame,
)
@@ -36,7 +37,6 @@ class UserIdleProcessor(FrameProcessor):
self._callback = callback
self._timeout = timeout
self._interrupted = False
self._create_idle_task()
async def _stop(self):
self._idle_task.cancel()
@@ -46,7 +46,9 @@ class UserIdleProcessor(FrameProcessor):
await super().process_frame(frame, direction)
# Check for end frames before processing
if isinstance(frame, (EndFrame, CancelFrame)):
if isinstance(frame, StartFrame):
self._create_idle_task()
elif isinstance(frame, (EndFrame, CancelFrame)):
await self._stop()
await self.push_frame(frame, direction)