Before you begin
You need a Baseten account and a Baseten API key. The real-time Python client also requires uv. Each model deployment runs on a dedicated GPU; review the instance cost before deploying. The shell commands on this page use macOS or Linux syntax. To download the recording: Run the following command:jfk.wav, an 11-second excerpt of John F. Kennedy’s inaugural address from the Whisper test assets. The file contains 16 kHz mono, signed 16-bit pulse-code modulation (PCM16) audio. The batch request uploads the WAV file; the real-time client reads the WAV container and sends only the audio samples.
Transcribe a batch
To deploy a batch transcription model:- Sign in to your workspace, then open Qwen3-ASR in the Model Library and choose Deploy Batch.
- Enter a Model name, review Hardware and pricing and Autoscaling, then choose Deploy.
- Wait for the deployment to become active. Open the model’s overview and choose Copy ID next to its name.
text. Compare it with the recording transcript shown alongside the request. Check that the full recording is present before accepting the result; wording and punctuation can vary.
This request sends the whole file without real-time pacing. Batch transcription uses HTTP; the real-time procedure uses a separate deployment and WebSocket client. Deactivate the tutorial deployment when you’re finished unless you plan to keep using it.
Deactivate the tutorial deployment
To stop the tutorial deployment:- In your workspace, choose Dedicated Inference, then select the model you deployed for this procedure.
- Open its deployment and choose Deactivate deployment.
- Confirm the action to stop its replicas.
Deploy a real-time model
This Model Library deployment uses the model-specific v1 protocol. A unified STT deployment uses v2 instead; the clients aren’t interchangeable. To deploy a real-time transcription model:- Sign in to your workspace, then open Qwen3-ASR in the Model Library and choose Deploy Streaming, the library’s label for the real-time deployment.
- Enter a Model name, review Hardware and pricing and Autoscaling, then choose Deploy.
- Wait for the deployment to become active. Open the model’s overview and choose Copy ID next to its name.
Connect to the endpoint
To configure the streaming client: Set your API key and the real-time model ID you copied:transcribe.py. The client connects to your model’s production WebSocket endpoint, sends audio while receiving transcripts, and closes after the server finishes processing the recording. See the Qwen3-ASR API reference for the message schema and audio requirements.
The client declares its Python requirement and WebSocket dependency in inline script metadata. The uv run command selects Python 3.11 and installs the dependency in an isolated environment. uv downloads Python if needed.
Complete transcribe.py client
Complete transcribe.py client
Stream the audio
To transcribe the recording in real time: Run the client with the supplied recording:input_audio_buffer.append JSON message with base64 audio. After the last chunk, it sends input_audio_buffer.commit to flush the remaining speech.
Sending and receiving run concurrently so you can receive partial transcripts while audio is still arriving. The client waits up to 60 seconds for each response and also bounds the total session time.
If the connection fails before any transcript appears, check that the real-time deployment is active and the model ID and API key belong to the same workspace. An HTTP 500 during model startup can mean the replica hasn’t finished loading; inspect the deployment’s Logs and retry after it becomes ready. A format error means your WAV differs from the supplied 16 kHz mono PCM16 recording.
Read the transcript
The client prints updates labeled with a transcription number. A partial is a revisable hypothesis for that number. A final completes that segment. Store finals once per number instead of concatenating every partial update. One run with the supplied recording produced these final lines (partial updates omitted):Transcript: line. Partial wording and the number of updates can vary between runs.
Finish the session
The client waits for a final message withis_end_of_audio_flush: true before closing the WebSocket. Closing immediately after sending the audio can lose the last transcript. If you interrupt the client with Ctrl+C, run the file again to get a complete result.
Your real-time transcription is complete when the client prints Transcript: and exits. Closing the connection releases the session; the deployment remains active according to its autoscaling settings.
Deactivate the tutorial deployment
To stop the tutorial deployment:- In your workspace, choose Dedicated Inference, then select the model you deployed for this procedure.
- Open its deployment and choose Deactivate deployment.
- Confirm the action to stop its replicas.
Transcribe with the unified API
Use this client for a unified STT server deployment provided by Baseten. Contact Baseten support to obtain a deployment and its model and deployment IDs. The Qwen3-ASR Deploy Streaming option in the Model Library uses v1 and doesn’t work with this client. The client targets a specific published deployment so you can validate v2 before promoting it to an environment. Unified STT presets use custom Docker servers and don’t support development deployments.Configure the v2 client
To connect to your unified deployment: Set your API key and the model and deployment IDs provided by Baseten:transcribe-v2.py. It checks the deployment’s advertised audio format and waits up to 60 seconds for session.created; a v1 deployment doesn’t send that event.
Complete transcribe-v2.py client
Complete transcribe-v2.py client
transcribe-v2.py
Stream the recording
To transcribe the recording with v2: Run the client with thejfk.wav recording from Before you begin. It contains 16 kHz mono PCM16 audio, which the Qwen3-ASR unified deployment accepts. Convert it first if your deployment advertises a different input format.
session.created, requests client_flush, and prints any refused settings. It sends 100 ms audio chunks at real-time pace while receiving partial transcripts. Each turn contains at most 10 seconds of audio and stays below the deployment’s max_turn_s limit. On the Qwen3-ASR unified deployment, the supplied recording spans 2 client turns. Deployments with shorter turn limits produce more turns. Transcript text and partial updates depend on the model.
The client flushes each turn and waits for its transcription.done before sending the next turn. This keeps flush results unambiguous when a recording exceeds the model’s turn limit. Fixed boundaries can split words; in a voice application, flush at your application’s utterance boundaries instead.
Confirm completion
Accept the result only when the client printsTranscript: and exits successfully. That line contains the joined final transcripts, without partial updates. Compare it with the recording transcript in Transcribe a batch.
A failed turn, a missing result, or an early socket close causes the client to exit with an error. Each receive has a 60-second timeout, and each turn has an overall timeout of its audio duration plus 120 seconds. Adjust these limits for your workload. The client sends close only after every turn has a final result; close code 1000 alone doesn’t confirm complete transcription.
If the connection fails, check that the deployment is active and that both IDs and the API key belong to the same workspace. For message fields and error codes, see Real-time transcription API (v2).
Closing the WebSocket releases the session. To stop the deployment’s replicas when you’re finished, follow Deactivate the tutorial deployment.
Next steps
- Measure voice inference performance under your expected traffic.
- Look up the unified STT protocol for v2 deployments.
- Look up the Qwen3-ASR streaming protocol to integrate the model into your application.
- Configure scale to zero to preserve an endpoint that can wake for later requests.