Not storing anymore the last frames received to display them in the idle processor.
This commit is contained in:
@@ -777,7 +777,6 @@ class PipelineTask(BasePipelineTask):
|
|||||||
"""
|
"""
|
||||||
running = True
|
running = True
|
||||||
last_frame_time = 0
|
last_frame_time = 0
|
||||||
frame_buffer = deque(maxlen=10) # Store last 10 frames
|
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
try:
|
try:
|
||||||
@@ -785,9 +784,6 @@ class PipelineTask(BasePipelineTask):
|
|||||||
self._idle_queue.get(), timeout=self._idle_timeout_secs
|
self._idle_queue.get(), timeout=self._idle_timeout_secs
|
||||||
)
|
)
|
||||||
|
|
||||||
if not isinstance(frame, InputAudioRawFrame):
|
|
||||||
frame_buffer.append(frame)
|
|
||||||
|
|
||||||
if isinstance(frame, StartFrame) or isinstance(frame, self._idle_timeout_frames):
|
if isinstance(frame, StartFrame) or isinstance(frame, self._idle_timeout_frames):
|
||||||
# If we find a StartFrame or one of the frames that prevents a
|
# If we find a StartFrame or one of the frames that prevents a
|
||||||
# time out we update the time.
|
# time out we update the time.
|
||||||
@@ -798,7 +794,7 @@ class PipelineTask(BasePipelineTask):
|
|||||||
# valid frames.
|
# valid frames.
|
||||||
diff_time = time.time() - last_frame_time
|
diff_time = time.time() - last_frame_time
|
||||||
if diff_time >= self._idle_timeout_secs:
|
if diff_time >= self._idle_timeout_secs:
|
||||||
running = await self._idle_timeout_detected(frame_buffer)
|
running = await self._idle_timeout_detected()
|
||||||
# Reset `last_frame_time` so we don't trigger another
|
# Reset `last_frame_time` so we don't trigger another
|
||||||
# immediate idle timeout if we are not cancelling. For
|
# immediate idle timeout if we are not cancelling. For
|
||||||
# example, we might want to force the bot to say goodbye
|
# example, we might want to force the bot to say goodbye
|
||||||
@@ -808,14 +804,11 @@ class PipelineTask(BasePipelineTask):
|
|||||||
self._idle_queue.task_done()
|
self._idle_queue.task_done()
|
||||||
|
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
running = await self._idle_timeout_detected(frame_buffer)
|
running = await self._idle_timeout_detected()
|
||||||
|
|
||||||
async def _idle_timeout_detected(self, last_frames: Deque[Frame]) -> bool:
|
async def _idle_timeout_detected(self) -> bool:
|
||||||
"""Handle idle timeout detection and optional cancellation.
|
"""Handle idle timeout detection and optional cancellation.
|
||||||
|
|
||||||
Args:
|
|
||||||
last_frames: Recent frames received before timeout for debugging.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Whether the pipeline task should continue running.
|
Whether the pipeline task should continue running.
|
||||||
"""
|
"""
|
||||||
@@ -823,10 +816,7 @@ class PipelineTask(BasePipelineTask):
|
|||||||
if self._cancelled:
|
if self._cancelled:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
logger.warning("Idle timeout detected. Last 10 frames received:")
|
logger.warning("Idle timeout detected.")
|
||||||
for i, frame in enumerate(last_frames, 1):
|
|
||||||
logger.warning(f"Frame {i}: {frame}")
|
|
||||||
|
|
||||||
await self._call_event_handler("on_idle_timeout")
|
await self._call_event_handler("on_idle_timeout")
|
||||||
if self._cancel_on_idle_timeout:
|
if self._cancel_on_idle_timeout:
|
||||||
logger.warning(f"Idle pipeline detected, cancelling pipeline task...")
|
logger.warning(f"Idle pipeline detected, cancelling pipeline task...")
|
||||||
|
|||||||
Reference in New Issue
Block a user