async def test_active_listening_resets_idle(self):
        """Test that bot speaking frames reset the idle timer because user is actively listening."""
        callback_called = asyncio.Event()

        async def idle_callback(processor: UserIdleProcessor) -> None:
            callback_called.set()

        processor = UserIdleProcessor(callback=idle_callback, timeout=0.2)

        frames_to_send = [
            # Start conversation
            UserStartedSpeakingFrame(),
            UserStoppedSpeakingFrame(),
            # Wait almost long enough for idle timeout
            SleepFrame(sleep=0.1),
            # Bot speaking frame should reset idle timer
            BotSpeakingFrame(),
            # Wait almost long enough for idle timeout again
            SleepFrame(sleep=0.1),
            # Another bot speaking frame resets timer again
            BotSpeakingFrame(),
            # Give some time for the idle timeout task to start (Python 3.10
            # doesn't really like when you create a task and then cancel it
            # right away).
            SleepFrame(sleep=0.1),
        ]

        expected_down_frames = [
            UserStartedSpeakingFrame,
            UserStoppedSpeakingFrame,
            BotSpeakingFrame,
            BotSpeakingFrame,
        ]

        await run_test(
            processor,
            frames_to_send=frames_to_send,
            expected_down_frames=expected_down_frames,
        )

        assert not callback_called.is_set(), (
            "Idle callback was called even though bot speaking frames reset the timer"
        )
Test that bot speaking frames reset the idle timer because user is actively listening.
tests/test_user_idle_processor.py