File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,25 @@ async def stop_session(self) -> None:
161161 await self ._session_done_evt .wait () # Wait for end of transcript event to indicate we can stop listening
162162 await self .close ()
163163
164+ async def force_end_of_utterance (self ) -> None :
165+ """
166+ This method sends a ForceEndOfUtterance message to the server to signal
167+ the end of an utterance.
168+
169+ Raises:
170+ ConnectionError: If the WebSocket connection fails.
171+ TranscriptionError: If the server reports an error during teardown.
172+ TimeoutError: If the connection or teardown times out.
173+
174+ Examples:
175+ Basic streaming:
176+ >>> async with AsyncClient() as client:
177+ ... await client.start_session()
178+ ... await client.send_audio(frame)
179+ ... await client.force_end_of_utterance()
180+ """
181+ await self .send_message ({"message" : ClientMessageType .FORCE_END_OF_UTTERANCE })
182+
164183 async def transcribe (
165184 self ,
166185 source : BinaryIO ,
Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ class ClientMessageType(str, Enum):
6363 SetRecognitionConfig: Updates transcription configuration during
6464 an active session (advanced use).
6565 GetSpeakers: Allows the client to request speaker data.
66+ AddChannelAudio: Indicates that audio data follows (not used in message
67+ headers, audio is sent as binary data).
68+ EndOfChannel: Signals that no more audio data will be sent.
69+ ForceEndOfUtterance: Signals that the end of an utterance has been reached.
6670
6771 Examples:
6872 >>> # Starting a recognition session
@@ -86,6 +90,7 @@ class ClientMessageType(str, Enum):
8690 GET_SPEAKERS = "GetSpeakers"
8791 ADD_CHANNEL_AUDIO = "AddChannelAudio"
8892 END_OF_CHANNEL = "EndOfChannel"
93+ FORCE_END_OF_UTTERANCE = "ForceEndOfUtterance"
8994
9095
9196class ServerMessageType (str , Enum ):
You can’t perform that action at this time.
0 commit comments