diff --git a/src/elevenlabs/realtime/connection.py b/src/elevenlabs/realtime/connection.py index 0f575662..da96e0ab 100644 --- a/src/elevenlabs/realtime/connection.py +++ b/src/elevenlabs/realtime/connection.py @@ -11,8 +11,8 @@ class RealtimeEvents(str, Enum): CLOSE = "close" SESSION_STARTED = "session_started" PARTIAL_TRANSCRIPT = "partial_transcript" - FINAL_TRANSCRIPT = "final_transcript" - FINAL_TRANSCRIPT_WITH_TIMESTAMPS = "final_transcript_with_timestamps" + COMMITTED_TRANSCRIPT = "committed_transcript" + COMMITTED_TRANSCRIPT_WITH_TIMESTAMPS = "committed_transcript_with_timestamps" ERROR = "error" @@ -31,7 +31,7 @@ class RealtimeConnection: }) connection.on(RealtimeEvents.PARTIAL_TRANSCRIPT, lambda data: print(data)) - connection.on(RealtimeEvents.FINAL_TRANSCRIPT, lambda data: print(data)) + connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, lambda data: print(data)) # Send audio connection.send({"audioBase64": audio_chunk}) @@ -132,8 +132,8 @@ async def send(self, data: typing.Dict[str, typing.Any]) -> None: async def commit(self) -> None: """ - Commits the transcription, signaling that all audio has been sent. - This finalizes the transcription and triggers a FINAL_TRANSCRIPT event. + Commits the segment, triggering a COMMITTED_TRANSCRIPT event and clearing the buffer. + It's recommend to commit often when using CommitStrategy.MANUAL to keep latency low. Raises: RuntimeError: If the WebSocket connection is not open @@ -148,7 +148,7 @@ async def commit(self) -> None: for chunk in audio_chunks: connection.send({"audioBase64": chunk}) - # Finalize the transcription + # Commit the audio segment await connection.commit() ``` """ @@ -175,8 +175,8 @@ async def close(self) -> None: Example: ```python - connection.on(RealtimeEvents.FINAL_TRANSCRIPT, async lambda data: ( - print("Final:", data["transcript"]), + connection.on(RealtimeEvents.COMMITTED_TRANSCRIPT, async lambda data: ( + print("Committed:", data["transcript"]), await connection.close() )) ``` diff --git a/src/elevenlabs/realtime/scribe.py b/src/elevenlabs/realtime/scribe.py index 9294c632..39357d12 100644 --- a/src/elevenlabs/realtime/scribe.py +++ b/src/elevenlabs/realtime/scribe.py @@ -28,7 +28,7 @@ class CommitStrategy(str, Enum): Strategy for committing transcription results. VAD: Voice Activity Detection - automatically commits when speech ends - MANUAL: Manual commit - requires calling commit() to finalize transcription + MANUAL: Manual commit - requires calling commit() to commit the segment """ VAD = "vad" MANUAL = "manual" @@ -95,7 +95,7 @@ class ScribeRealtime: Example (URL-based): ```python connection = await elevenlabs.speech_to_text.realtime.connect({ - "model_id": "scribe_realtime_v2", + "model_id": "scribe_v2_realtime", "url": "https://stream.example.com/audio.mp3" }) ``` @@ -103,7 +103,7 @@ class ScribeRealtime: Example (Manual chunks): ```python connection = await elevenlabs.speech_to_text.realtime.connect({ - "model_id": "scribe_realtime_v2", + "model_id": "scribe_v2_realtime", "audio_format": AudioFormat.PCM_16000, "sample_rate": 16000 }) @@ -138,13 +138,13 @@ async def connect( ```python # URL-based streaming connection = await elevenlabs.speech_to_text.realtime.connect({ - "model_id": "scribe_realtime_v2", + "model_id": "scribe_v2_realtime", "url": "https://stream.example.com/audio.mp3", }) # Manual chunks connection = await elevenlabs.speech_to_text.realtime.connect({ - "model_id": "scribe_realtime_v2", + "model_id": "scribe_v2_realtime", "audio_format": AudioFormat.PCM_16000, "sample_rate": 16000, "commit_strategy": CommitStrategy.MANUAL @@ -367,5 +367,5 @@ def _build_websocket_url( params.append(f"language_code={language_code}") query_string = "&".join(params) - return f"{base}/v1/speech-to-text/realtime-beta?{query_string}" + return f"{base}/v1/speech-to-text/realtime?{query_string}"