Merge pull request #3594 from pipecat-ai/aleix/user-turn-controller-reset-timeout-on-interims
UserTurnController: reset user turn timeout with interim transcriptions
This commit is contained in:
1
changelog/3594.fixed.md
Normal file
1
changelog/3594.fixed.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Fixed `UserTurnController` to reset user turn timeout when interim transcriptions are received.
|
||||||
@@ -11,6 +11,7 @@ from typing import Optional, Type
|
|||||||
|
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
Frame,
|
Frame,
|
||||||
|
InterimTranscriptionFrame,
|
||||||
TranscriptionFrame,
|
TranscriptionFrame,
|
||||||
UserStartedSpeakingFrame,
|
UserStartedSpeakingFrame,
|
||||||
UserStoppedSpeakingFrame,
|
UserStoppedSpeakingFrame,
|
||||||
@@ -156,7 +157,7 @@ class UserTurnController(BaseObject):
|
|||||||
await self._handle_vad_user_started_speaking(frame)
|
await self._handle_vad_user_started_speaking(frame)
|
||||||
elif isinstance(frame, VADUserStoppedSpeakingFrame):
|
elif isinstance(frame, VADUserStoppedSpeakingFrame):
|
||||||
await self._handle_vad_user_stopped_speaking(frame)
|
await self._handle_vad_user_stopped_speaking(frame)
|
||||||
elif isinstance(frame, TranscriptionFrame):
|
elif isinstance(frame, (TranscriptionFrame, InterimTranscriptionFrame)):
|
||||||
await self._handle_transcription(frame)
|
await self._handle_transcription(frame)
|
||||||
|
|
||||||
for strategy in self._user_turn_strategies.start or []:
|
for strategy in self._user_turn_strategies.start or []:
|
||||||
@@ -209,8 +210,8 @@ class UserTurnController(BaseObject):
|
|||||||
# The user stopped talking, let's reset the user turn timeout.
|
# The user stopped talking, let's reset the user turn timeout.
|
||||||
self._user_turn_stop_timeout_event.set()
|
self._user_turn_stop_timeout_event.set()
|
||||||
|
|
||||||
async def _handle_transcription(self, frame: TranscriptionFrame):
|
async def _handle_transcription(self, frame: TranscriptionFrame | InterimTranscriptionFrame):
|
||||||
# We have creceived a transcription, let's reset the user turn timeout.
|
# We have received a transcription, let's reset the user turn timeout.
|
||||||
self._user_turn_stop_timeout_event.set()
|
self._user_turn_stop_timeout_event.set()
|
||||||
|
|
||||||
async def _on_push_frame(
|
async def _on_push_frame(
|
||||||
|
|||||||
Reference in New Issue
Block a user