Skip to content
Open
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
16 changes: 8 additions & 8 deletions src/elevenlabs/realtime/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand All @@ -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})
Expand Down Expand Up @@ -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
Expand All @@ -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()
```
"""
Expand All @@ -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()
))
```
Expand Down
12 changes: 6 additions & 6 deletions src/elevenlabs/realtime/scribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -95,15 +95,15 @@ 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"
})
```

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