Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sdk/voice/speechmatics/voice/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions sdk/voice/speechmatics/voice/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


# ==============================================================================
Expand Down Expand Up @@ -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(
Expand Down