user started/stopped speaking frames and interruption frames
This commit is contained in:
@@ -248,7 +248,6 @@ class OpenAILLMServiceRealtimeBeta(LLMService):
|
|||||||
session_properties: events.SessionProperties = events.SessionProperties(),
|
session_properties: events.SessionProperties = events.SessionProperties(),
|
||||||
start_audio_paused: bool = False,
|
start_audio_paused: bool = False,
|
||||||
send_transcription_frames: bool = True,
|
send_transcription_frames: bool = True,
|
||||||
send_user_started_speaking_frames: bool = False,
|
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
super().__init__(base_url=base_url, **kwargs)
|
super().__init__(base_url=base_url, **kwargs)
|
||||||
@@ -258,8 +257,6 @@ class OpenAILLMServiceRealtimeBeta(LLMService):
|
|||||||
self._session_properties: events.SessionProperties = session_properties
|
self._session_properties: events.SessionProperties = session_properties
|
||||||
self._audio_input_paused = start_audio_paused
|
self._audio_input_paused = start_audio_paused
|
||||||
self._send_transcription_frames = send_transcription_frames
|
self._send_transcription_frames = send_transcription_frames
|
||||||
# todo: wire _send_user_started_speaking_frames up correctly
|
|
||||||
self._send_user_started_speaking_frames = send_user_started_speaking_frames
|
|
||||||
self._websocket = None
|
self._websocket = None
|
||||||
self._receive_task = None
|
self._receive_task = None
|
||||||
self._context = None
|
self._context = None
|
||||||
@@ -336,6 +333,7 @@ class OpenAILLMServiceRealtimeBeta(LLMService):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# frame processing
|
# frame processing
|
||||||
#
|
#
|
||||||
@@ -608,17 +606,18 @@ class OpenAILLMServiceRealtimeBeta(LLMService):
|
|||||||
|
|
||||||
async def _handle_evt_speech_started(self, evt):
|
async def _handle_evt_speech_started(self, evt):
|
||||||
await self._truncate_current_audio_response()
|
await self._truncate_current_audio_response()
|
||||||
if self._send_user_started_speaking_frames:
|
# todo: might need to guard sending these when we fully support using either openai
|
||||||
await self.push_frame(UserStartedSpeakingFrame())
|
# turn detection of Pipecat turn detection
|
||||||
await self.push_frame(StartInterruptionFrame())
|
await self._start_interruption() # cancels this processor task
|
||||||
logger.debug("User started speaking")
|
await self.push_frame(StartInterruptionFrame()) # cancels downstream tasks
|
||||||
|
await self.push_frame(UserStartedSpeakingFrame())
|
||||||
|
|
||||||
async def _handle_evt_speech_stopped(self, evt):
|
async def _handle_evt_speech_stopped(self, evt):
|
||||||
await self.start_ttfb_metrics()
|
await self.start_ttfb_metrics()
|
||||||
await self.start_processing_metrics()
|
await self.start_processing_metrics()
|
||||||
if self._send_user_started_speaking_frames:
|
await self._stop_interruption()
|
||||||
await self.push_frame(UserStoppedSpeakingFrame())
|
await self.push_frame(StopInterruptionFrame())
|
||||||
await self.push_frame(StopInterruptionFrame())
|
await self.push_frame(UserStoppedSpeakingFrame())
|
||||||
|
|
||||||
async def _handle_evt_error(self, evt):
|
async def _handle_evt_error(self, evt):
|
||||||
# Errors are fatal to this connection. Send an ErrorFrame.
|
# Errors are fatal to this connection. Send an ErrorFrame.
|
||||||
|
|||||||
Reference in New Issue
Block a user