diff --git a/sdk/voice/speechmatics/voice/_client.py b/sdk/voice/speechmatics/voice/_client.py index c0988dd..7a3781d 100644 --- a/sdk/voice/speechmatics/voice/_client.py +++ b/sdk/voice/speechmatics/voice/_client.py @@ -318,6 +318,7 @@ def __init__( ) # Uses ForceEndOfUtterance message + # Todo - fix this logic as use FEOU isn't the same as just not using fixed. self._uses_forced_eou: bool = not self._uses_fixed_eou self._forced_eou_active: bool = False self._last_forced_eou_latency: float = 0.0 @@ -1421,6 +1422,7 @@ async def _emit_end_of_turn(self) -> None: # Flag as turn active self._turn_active = False + # Metadata (for LAST view) metadata = MessageTimeMetadata(start_time=self._turn_start_time, end_time=self._previous_view.end_time) @@ -1526,6 +1528,10 @@ async def _calculate_finalize_delay( # Smart Turn enabled if self._smart_turn_detector: annotation.add(AnnotationFlags.SMART_TURN_ACTIVE) + # If Smart Turn hasn't returned a result yet but is enabled, add NO_SIGNAL annotation. + # This covers the case where the TTL fires before VAD triggers Smart Turn inference. + if not annotation.has(AnnotationFlags.SMART_TURN_TRUE) and not annotation.has(AnnotationFlags.SMART_TURN_FALSE): + annotation.add(AnnotationFlags.SMART_TURN_NO_SIGNAL) else: annotation.add(AnnotationFlags.SMART_TURN_INACTIVE) diff --git a/sdk/voice/speechmatics/voice/_models.py b/sdk/voice/speechmatics/voice/_models.py index e43207e..f613330 100644 --- a/sdk/voice/speechmatics/voice/_models.py +++ b/sdk/voice/speechmatics/voice/_models.py @@ -261,6 +261,7 @@ class AnnotationFlags(str, Enum): SMART_TURN_INACTIVE = "smart_turn_inactive" SMART_TURN_TRUE = "smart_turn_true" SMART_TURN_FALSE = "smart_turn_false" + SMART_TURN_NO_SIGNAL = "smart_turn_no_signal" # ============================================================================== @@ -445,6 +446,9 @@ class EndOfTurnConfig(BaseModel): EndOfTurnPenaltyItem( penalty=2.0, annotation=[AnnotationFlags.SMART_TURN_FALSE, AnnotationFlags.SMART_TURN_ACTIVE] ), + EndOfTurnPenaltyItem( + penalty=1.5, annotation=[AnnotationFlags.SMART_TURN_NO_SIGNAL, AnnotationFlags.SMART_TURN_ACTIVE] + ), # # VAD - only applied when smart turn is not in use and on the speaker stopping EndOfTurnPenaltyItem(