Skip to main content
Real-time speech recognition (Qwen-ASR-Realtime)

Client events for Qwen-ASR-Realtime

This page documents client-to-server events for the Qwen-ASR Realtime WebSocket API. Each section covers an event type, its parameters, and server responses.

For a feature overview and complete sample code, see Real-time speech recognition - Qwen. For server-to-client events, see Server events for Qwen-ASR-Realtime.

Event lifecycle

A typical session follows this sequence:
  1. Establish a WebSocket connection.
  2. Send session.update to configure audio format, language, and VAD settings.
  3. Send input_audio_buffer.append repeatedly to stream audio data.
  4. In Manual mode, send input_audio_buffer.commit to trigger recognition for a complete utterance. In VAD mode, the server triggers recognition automatically.
  5. Send session.finish to end the session, then disconnect after receiving the session.finished response.

session.update

Configures the session. Send this immediately after establishing the WebSocket connection to set the audio format, the language, and VAD parameters. If omitted, defaults apply. The server responds with a session.updated event on success.

Parameters

ParameterTypeRequiredDescription
typestringYesFixed value: session.update.
event_idstringYesA unique event ID.
sessionobjectYesSession configuration object. See the session configuration table below.

Session configuration

ParameterTypeRequiredDescription
input_audio_formatstringNoAudio encoding format. Valid values: pcm, opus. Default: pcm.
sample_rateintegerNoAudio sampling rate in Hz. Valid values: 16000, 8000. Default: 16000. Setting 8000 causes server-side upsampling to 16,000 Hz (minor delay). Use 8000 only for natively 8,000 Hz audio like telephony.
input_audio_transcriptionobjectNoSpeech recognition settings.
input_audio_transcription.languagestringNoLanguage of the audio. See the supported languages table below.
input_audio_transcription.corpus.textstringNoContext text for contextual biasing -- background text, entity vocabularies, or reference material that improves recognition accuracy. Maximum: 10,000 tokens.
turn_detectionobjectNoVAD configuration. Set to null for Manual mode. If present, VAD mode is enabled.
turn_detection.typestringRequired when turn_detection is setFixed value: server_vad.
turn_detection.thresholdfloatNoVAD sensitivity threshold. Default: 0.2. Valid range: [-1, 1]. Lower values increase sensitivity (may trigger on background noise). Higher values reduce sensitivity and avoid false triggers in noisy environments. See recommended VAD presets below.
turn_detection.silence_duration_msintegerNoSilence duration in milliseconds marking utterance end. Default: 800. Valid range: [200, 6000]. Shorter durations (e.g., 300 ms) speed up responses but may split natural pauses. Longer durations (e.g., 1,200 ms) handle pauses better but increase latency. See recommended VAD presets below.
Use these presets as starting points. Adjust based on your results:
Presetthresholdsilence_duration_msBest for
Low latency0.0400Fast-paced interactions like voice commands or agent assist, where quick responses matter more than handling long pauses
Balanced (default)0.2800General-purpose transcription with a balance between responsiveness and accuracy

Supported languages

CodeLanguage
zhChinese (Mandarin, Sichuanese, Minnan, and Wu)
yueCantonese
enEnglish
jaJapanese
deGerman
koKorean
ruRussian
frFrench
ptPortuguese
arArabic
itItalian
esSpanish
hiHindi
idIndonesian
thThai
trTurkish
ukUkrainian
viVietnamese
csCzech
daDanish
filFilipino
fiFinnish
isIcelandic
msMalay
noNorwegian
plPolish
svSwedish

Example

{
    "event_id": "event_123",
    "type": "session.update",
    "session": {
        "input_audio_format": "pcm",
        "sample_rate": 16000,
        "input_audio_transcription": {
            "language": "zh"
        },
        "turn_detection": {
            "type": "server_vad",
            "threshold": 0.0,
            "silence_duration_ms": 400
        }
    }
}

input_audio_buffer.append

Streams an audio chunk to the server's input buffer -- the core event for sending audio data. Behavior differs by interaction mode:
  • VAD mode: The server monitors the buffer for voice activity and automatically triggers recognition.
  • Manual mode: The client controls utterance boundaries. Send smaller chunks for lower latency.
The audio field contains Base64-encoded data. In Manual mode, maximum size per event: 15 MiB. The server does not send a confirmation response.

Parameters

ParameterTypeRequiredDescription
typestringYesFixed value: input_audio_buffer.append.
event_idstringYesA unique event ID.
audiostringYesBase64-encoded audio data.

Example

{
    "event_id": "event_2728",
    "type": "input_audio_buffer.append",
    "audio": "<Base64-encoded-audio-data>"
}

input_audio_buffer.commit

Triggers recognition for all audio in the buffer as a single utterance. Use in Manual mode when your application controls utterance boundaries (e.g., push-to-talk). Disabled in VAD mode. The server responds with an input_audio_buffer.committed event on success.

Parameters

ParameterTypeRequiredDescription
typestringYesFixed value: input_audio_buffer.commit.
event_idstringYesA unique event ID.

Example

{
    "event_id": "event_789",
    "type": "input_audio_buffer.commit"
}

session.finish

Ends the session. Server response depends on speech detection:
  • Speech detected: The server completes final recognition, sends a conversation.item.input_audio_transcription.completed event with the result, then sends a session.finished event.
  • No speech detected: The server sends session.finished directly.
After receiving session.finished, disconnect the WebSocket connection.

Parameters

ParameterTypeRequiredDescription
typestringYesFixed value: session.finish.
event_idstringYesA unique event ID.

Example

{
    "event_id": "event_341",
    "type": "session.finish"
}
Text Generation
Image Generation
  • FAQ
Video Generation
Audio
Realtime API
Text Embedding
Model Production