2121from ._models import TranscriptionConfig
2222from ._models import TranslationConfig
2323
24+ _UNSET = object ()
2425
2526class AsyncClient (_BaseClient ):
2627 """
@@ -167,7 +168,7 @@ async def stop_session(self) -> None:
167168 await self ._session_done_evt .wait () # Wait for end of transcript event to indicate we can stop listening
168169 await self .close ()
169170
170- async def force_end_of_utterance (self , * , timestamp : Optional [ float ] = None ) -> None :
171+ async def force_end_of_utterance (self , * , timestamp = _UNSET ) -> None :
171172 """
172173 This method sends a ForceEndOfUtterance message to the server to signal
173174 the end of an utterance. Forcing end of utterance will cause the final
@@ -193,10 +194,17 @@ async def force_end_of_utterance(self, *, timestamp: Optional[float] = None) ->
193194 ... await client.force_end_of_utterance()
194195 """
195196
196- if timestamp is None :
197- timestamp = self .audio_seconds_sent
197+ message : dict [str ,Any ] = {"message" : ClientMessageType .FORCE_END_OF_UTTERANCE }
198198
199- await self .send_message ({"message" : ClientMessageType .FORCE_END_OF_UTTERANCE , "timestamp" : timestamp })
199+ if timestamp is _UNSET :
200+ # default: auto-set from audio_seconds_sent
201+ message ["timestamp" ] = self .audio_seconds_sent
202+ elif timestamp is not None :
203+ # user provided explicit value
204+ message ["timestamp" ] = timestamp
205+ # if timestamp is None: omit entirely
206+
207+ await self .send_message (message )
200208
201209 @property
202210 def audio_seconds_sent (self ) -> float :
0 commit comments