Merge pull request #1029 from Vaibhav159/vl_fixing_idle_frame_processor_logic
fixing IdleFrameProcessor and UserIdleProcessor init logic
This commit is contained in:
@@ -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`
|
- Fixed an issue where setting the voice and model for `RimeHttpTTSService`
|
||||||
wasn't working.
|
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
|
## [0.0.52] - 2024-12-24
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import Awaitable, Callable, List
|
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
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
|
|
||||||
|
|
||||||
@@ -31,11 +31,12 @@ class IdleFrameProcessor(FrameProcessor):
|
|||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
self._types = types
|
self._types = types
|
||||||
|
|
||||||
self._create_idle_task()
|
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
await super().process_frame(frame, direction)
|
await super().process_frame(frame, direction)
|
||||||
|
|
||||||
|
if isinstance(frame, StartFrame):
|
||||||
|
self._create_idle_task()
|
||||||
|
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
|
|
||||||
# If we are not waiting for any specific frame set the event, otherwise
|
# If we are not waiting for any specific frame set the event, otherwise
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from pipecat.frames.frames import (
|
|||||||
CancelFrame,
|
CancelFrame,
|
||||||
EndFrame,
|
EndFrame,
|
||||||
Frame,
|
Frame,
|
||||||
|
StartFrame,
|
||||||
UserStartedSpeakingFrame,
|
UserStartedSpeakingFrame,
|
||||||
UserStoppedSpeakingFrame,
|
UserStoppedSpeakingFrame,
|
||||||
)
|
)
|
||||||
@@ -36,7 +37,6 @@ class UserIdleProcessor(FrameProcessor):
|
|||||||
self._callback = callback
|
self._callback = callback
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
self._interrupted = False
|
self._interrupted = False
|
||||||
self._create_idle_task()
|
|
||||||
|
|
||||||
async def _stop(self):
|
async def _stop(self):
|
||||||
self._idle_task.cancel()
|
self._idle_task.cancel()
|
||||||
@@ -46,7 +46,9 @@ class UserIdleProcessor(FrameProcessor):
|
|||||||
await super().process_frame(frame, direction)
|
await super().process_frame(frame, direction)
|
||||||
|
|
||||||
# Check for end frames before processing
|
# 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._stop()
|
||||||
|
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
|
|||||||
Reference in New Issue
Block a user