rotate_segment called while previous segment is st...
# ask-ai
m
rotate_segment called while previous segment is still being rotated
t
Thanks for reaching out, Jack. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! That error message, "rotate_segment called while previous segment is still being rotated," usually pops up when
rotate_segment
gets called before the last rotation has finished. It often happens if calls overlap or if the previous task isn’t properly awaited. Here’s a simple way to fix it: • Make sure
rotate_segment()
only runs after the previous rotation task has wrapped up. You can add a quick check to see if the previous task is done before moving on. • For example, try updating your code like this:
Copy code
async def rotate_segment_safely():
    if not self._rotate_segment_atask.done():
        await self._rotate_segment_atask  # Wait for the previous task to complete
    self.rotate_segment()
If you want, feel free to share more about how you’re calling
rotate_segment()
or ask any questions—I’m here to help! Sources: livekit-agents/livekit/agents/voice/transcription/synchronizer.py