Skip to Content
agent-cname.modelsell.cc Docs
Audio & MoreElevenLabs Audio Integration

ElevenLabs Speech to Text

Transcribe a file with Scribe or stream PCM audio for partial and committed transcripts over WebSocket.

Set the agent-cname.modelsell.cc URLs and API key as shown in the ElevenLabs quickstart. Scribe transcribes the language spoken in the audio. Speech to Text overview

Use caseModel IDsagent-cname.modelsell.cc route
Recorded audioscribe_v3, scribe_v2, scribe_v2_medicalPOST /elevenlabs/v1/speech-to-text
Realtime audioscribe_v3_live, scribe_v2_realtimeGET /elevenlabs/v1/speech-to-text/realtime over WebSocket

Choose scribe_v2_medical for batch audio that contains clinical terms. Scribe v3 Live Medical is available within ElevenAgents. Scribe models

Transcribe a file

Use multipart form data with exactly one file and an explicit model_id. Leave language_code out for automatic detection. The upstream minimum audio length is 100 ms. Your agent-cname.modelsell.cc gateway's upload limit also applies. Create transcript

curl --fail-with-body "$MODELSELL_BASE_URL/elevenlabs/v1/speech-to-text" \
  -H "xi-api-key: $MODELSELL_API_KEY" \
  -F 'model_id=scribe_v3' \
  -F 'file=@speech.mp3' \
  -F 'language_code=en' \
  -F 'timestamps_granularity=word' \
  -F 'diarize=true'
Optional form fieldEffect
language_codeLanguage hint using ISO 639-1 or ISO 639-3
timestamps_granularityword by default, or character or none
diarize, num_speakersAdd speaker labels and optionally specify the expected number of speakers, from 1 to 32
tag_audio_eventsInclude detected audio events, enabled by default
secondary_language_codes, numbers_formatWith scribe_v3, hint at other languages or render numbers as digits or words
file_formatUse pcm_s16le_16 for raw 16 kHz, signed 16-bit little-endian mono audio. Use the default other for formats such as MP3 or WAV

The JSON response includes text, the detected language_code, and a words array. Where requested, entries can include start and end in seconds and speaker_id. The array can also contain spacing and audio-event entries. For other model-dependent features such as entity detection and transcript editing, check the upstream field rules. Transcript response and parameters

Use the file upload for agent-cname.modelsell.cc. Provider-side URLs, asynchronous webhooks, independent multichannel transcription, and the provider's speaker library are outside this route's scope. Standard transcript diarization remains available.

Realtime WebSocket

Pass model_id in the query string. It defaults to scribe_v2_realtime. This example selects scribe_v3_live, raw PCM at 16 kHz, manual commit, and word timestamps. The gateway also accepts pcm_8000, pcm_22050, pcm_24000, pcm_44100, pcm_48000, and ulaw_8000. Match the actual audio encoding to audio_format. Scribe WebSocket reference

MessageDirectionWhen to use it
session_startedServer to clientWait for this before streaming audio
input_audio_chunkClient to serverSet audio_base_64, sample_rate, and commit. Set commit: true on the last chunk of a segment in manual mode
partial_transcriptServer to clientDisplay provisional text
committed_transcriptServer to clientUse as the finalized text for the segment
committed_transcript_with_timestampsServer to clientRead the additional timestamped result when include_timestamps=true

Prepare a short recording for the example. The PCM file contains only sample bytes. Supply a WAV or MP3 source to FFmpeg and stream the converted file.

ffmpeg -i speech.mp3 -ac 1 -ar 16000 -c:a pcm_s16le -f s16le speech.pcm
python -m pip install websocket-client
import base64
import json
import os
import time
from pathlib import Path
from urllib.parse import urlencode

from websocket import create_connection

audio = Path("speech.pcm").read_bytes()
if not audio or len(audio) % 2:
    raise ValueError("Expected a nonempty file of 16-bit PCM samples")

base = os.environ["MODELSELL_WS_URL"].rstrip("/")
query = urlencode({
    "model_id": "scribe_v3_live",
    "audio_format": "pcm_16000",
    "commit_strategy": "manual",
    "include_timestamps": "true",
})
socket = create_connection(
    f"{base}/elevenlabs/v1/speech-to-text/realtime?{query}",
    header=[f"Authorization: Bearer {os.environ['MODELSELL_API_KEY']}"],
    timeout=30,
)

try:
    start = json.loads(socket.recv())
    if start.get("message_type") != "session_started":
        raise RuntimeError(start)

    chunk_bytes = 3200
    for offset in range(0, len(audio), chunk_bytes):
        chunk = audio[offset:offset + chunk_bytes]
        last = offset + len(chunk) == len(audio)
        socket.send(json.dumps({
            "message_type": "input_audio_chunk",
            "audio_base_64": base64.b64encode(chunk).decode("ascii"),
            "sample_rate": 16000,
            "commit": last,
        }))
        if not last:
            time.sleep(len(chunk) / 32000)

    while True:
        event = json.loads(socket.recv())
        kind = event.get("message_type")
        if kind == "committed_transcript_with_timestamps":
            print(json.dumps({"text": event["text"], "words": event.get("words", [])},
                             ensure_ascii=False))
            break
        if kind not in {"partial_transcript", "committed_transcript"}:
            raise RuntimeError(event)
finally:
    socket.close()

For continuous capture, read messages while sending audio. commit_strategy=vad commits after a pause. scribe_v3_live also supports commit_strategy=turn_prediction, multilang_mode=true, and realtime diarization. The optional keyterm_library belongs in the first audio message on that model. Keep the connection open for the final result of the last segment. Commit strategies · Keyterms

Batch usage comes from the uploaded file's duration. Formats the gateway cannot measure require a configured per-request price. Realtime usage is estimated from the audio bytes sent in the selected format.

On this page