Skip to content

Commit 3a4dac4

Browse files
author
Georgios Hadjiharalambous
committed
add the capability to disable the timestamp in Feou in cases the transcriber doesnt support the timestamp as its an old version < 15.2.0
1 parent be8d162 commit 3a4dac4

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

sdk/rt/speechmatics/rt/_async_client.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from ._models import TranscriptionConfig
2222
from ._models import TranslationConfig
2323

24+
_UNSET = object()
2425

2526
class 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

Comments
 (0)