SegmentedSTTService: use VAD user started/stopped speaking frames
This commit is contained in:
@@ -20,8 +20,8 @@ from pipecat.frames.frames import (
|
|||||||
StartFrame,
|
StartFrame,
|
||||||
STTMuteFrame,
|
STTMuteFrame,
|
||||||
STTUpdateSettingsFrame,
|
STTUpdateSettingsFrame,
|
||||||
UserStartedSpeakingFrame,
|
VADUserStartedSpeakingFrame,
|
||||||
UserStoppedSpeakingFrame,
|
VADUserStoppedSpeakingFrame,
|
||||||
)
|
)
|
||||||
from pipecat.processors.frame_processor import FrameDirection
|
from pipecat.processors.frame_processor import FrameDirection
|
||||||
from pipecat.services.ai_service import AIService
|
from pipecat.services.ai_service import AIService
|
||||||
@@ -252,20 +252,15 @@ class SegmentedSTTService(STTService):
|
|||||||
"""Process frames, handling VAD events and audio segmentation."""
|
"""Process frames, handling VAD events and audio segmentation."""
|
||||||
await super().process_frame(frame, direction)
|
await super().process_frame(frame, direction)
|
||||||
|
|
||||||
if isinstance(frame, UserStartedSpeakingFrame):
|
if isinstance(frame, VADUserStartedSpeakingFrame):
|
||||||
await self._handle_user_started_speaking(frame)
|
await self._handle_user_started_speaking(frame)
|
||||||
elif isinstance(frame, UserStoppedSpeakingFrame):
|
elif isinstance(frame, VADUserStoppedSpeakingFrame):
|
||||||
await self._handle_user_stopped_speaking(frame)
|
await self._handle_user_stopped_speaking(frame)
|
||||||
|
|
||||||
async def _handle_user_started_speaking(self, frame: UserStartedSpeakingFrame):
|
async def _handle_user_started_speaking(self, frame: VADUserStartedSpeakingFrame):
|
||||||
if frame.emulated:
|
|
||||||
return
|
|
||||||
self._user_speaking = True
|
self._user_speaking = True
|
||||||
|
|
||||||
async def _handle_user_stopped_speaking(self, frame: UserStoppedSpeakingFrame):
|
async def _handle_user_stopped_speaking(self, frame: VADUserStoppedSpeakingFrame):
|
||||||
if frame.emulated:
|
|
||||||
return
|
|
||||||
|
|
||||||
self._user_speaking = False
|
self._user_speaking = False
|
||||||
|
|
||||||
content = io.BytesIO()
|
content = io.BytesIO()
|
||||||
|
|||||||
Reference in New Issue
Block a user