Alibaba · Qwen · Realtime ASR
Qwen Audio 3.0 ASR Flash Streaming
Realtime multilingual ASR with incremental transcripts for streaming audio.
qwen-audio-3-asr-streaming-sgCurrent model-specific price from our catalog. Requests require your project API key and sufficient balance. Availability is checked at execution time.
Input and capabilities
Connect over WebSocket. After session.updated, send mono PCM16 little-endian audio at 16 kHz. The direct streaming session supports up to 30 seconds of audio.
- transcription
- realtime input
- streaming output
- word timestamps
- segment timestamps
- hotwords
- partial transcripts
- endpointing
Automatic language detection: supported.
Supported language codes: zh-CN, en, ja, ko, vi, th, id, ms, tl, hi, ar, fr, de, es, pt, ru, it, nl, sv, da, fi, no, el, pl, cs, hu, ro, bg, hr, sk.
API endpoint
WEBSOCKET wss://api.speechinfra.com/v1/inference/qwen-audio-3-asr-streaming-sg/realtime
Authenticate with your Speechinfra project key. Read the quickstart and billing guide.
Python
# pip install websockets
# audio.pcm: mono, 16 kHz, signed PCM16 little-endian; <= 30 seconds.
import asyncio, json, os
from pathlib import Path
from websockets.asyncio.client import connect
async def main():
headers = {"Authorization": "Bearer " + os.environ["SPEECH_API_KEY"]}
async with connect("wss://api.speechinfra.com/v1/inference/qwen-audio-3-asr-streaming-sg/realtime", additional_headers=headers) as socket:
await socket.send("{\"semantic_punctuation_enabled\":false,\"max_sentence_silence\":1300,\"multi_threshold_mode_enabled\":false,\"heartbeat\":false,\"type\":\"session.configure\"}")
while True:
event = json.loads(await socket.recv())
if event["type"] == "error":
raise RuntimeError(event)
if event["type"] == "session.updated":
break
async def send():
audio = Path("audio.pcm").read_bytes()
assert 0 < len(audio) <= 960000 and len(audio) % 2 == 0
for i in range(0, len(audio), 3200):
await socket.send(audio[i:i+3200])
await asyncio.sleep(0.1)
await socket.send('{"type":"session.close"}')
sender = asyncio.create_task(send())
try:
async with asyncio.timeout(90):
async for message in socket:
print(message)
finally:
sender.cancel()
asyncio.run(main())JavaScript / browser
// Use from the console origin with a Speech Cloud project key.
// apiKey is a Speech Cloud project key, never a provider key.
const socket = new WebSocket("wss://api.speechinfra.com/v1/inference/qwen-audio-3-asr-streaming-sg/realtime", ['speech', apiKey]);
socket.onopen = () => socket.send("{\"semantic_punctuation_enabled\":false,\"max_sentence_silence\":1300,\"multi_threshold_mode_enabled\":false,\"heartbeat\":false,\"type\":\"session.configure\"}");
socket.onmessage = ({data}) => {
const event = JSON.parse(data);
console.log(event);
if (event.type === 'session.updated') {
// Send mono PCM16 / 16 kHz binary frames, <= 30 s in total.
// After the final frame: socket.send(JSON.stringify({type:'session.close'}));
}
};
// For a complete file-streaming example: scripts/test_models.pyRequest parameters
Generated from the API schema for this deployment. Conditional parameters apply only when their controlling setting is enabled.
| Parameter | Type | Details |
|---|---|---|
language_hints | array | max 4 items |
vocabulary_id | string | max 200 chars |
vocabulary | object | max 2000 entries |
context | string | max 400 chars |
semantic_punctuation_enabled | boolean | default: false |
max_sentence_silence | integer | default: 1300 · min: 200 · max: 6000 |
multi_threshold_mode_enabled | boolean | default: false Applies when: |
speech_noise_threshold | number | min: -1 · max: 1 |
heartbeat | boolean | default: false |
type | string | enum: session.configure · default: "session.configure" All accepted values[ "session.configure" ] |
Complete request schema
{
"type": "object",
"additionalProperties": false,
"required": [],
"properties": {
"language_hints": {
"type": "array",
"items": {
"type": "string",
"enum": [
"zh-CN",
"en",
"ja",
"ko",
"vi",
"th",
"id",
"ms",
"tl",
"hi",
"ar",
"fr",
"de",
"es",
"pt",
"ru",
"it",
"nl",
"sv",
"da",
"fi",
"no",
"el",
"pl",
"cs",
"hu",
"ro",
"bg",
"hr",
"sk"
]
},
"maxItems": 4
},
"vocabulary_id": {
"type": "string",
"maxLength": 200
},
"vocabulary": {
"type": "object",
"additionalProperties": {
"type": "integer",
"enum": [
1,
2,
3,
4,
5,
50
]
},
"maxProperties": 2000
},
"context": {
"type": "string",
"maxLength": 400
},
"semantic_punctuation_enabled": {
"type": "boolean",
"default": false
},
"max_sentence_silence": {
"type": "integer",
"minimum": 200,
"maximum": 6000,
"default": 1300
},
"multi_threshold_mode_enabled": {
"type": "boolean",
"default": false,
"visibleWhen": {
"semantic_punctuation_enabled": false
}
},
"speech_noise_threshold": {
"type": "number",
"minimum": -1,
"maximum": 1
},
"heartbeat": {
"type": "boolean",
"default": false
},
"type": {
"type": "string",
"enum": [
"session.configure"
],
"default": "session.configure"
}
}
}Response schema
Returns JSON events over the WebSocket connection.
View complete response schema
{
"type": "object",
"description": "JSON server events. Send binary mono PCM16 at 16 kHz after session.updated; session.close drains and returns session.closed.",
"properties": {
"type": {
"enum": [
"session.created",
"session.updated",
"session.routed",
"transcript.partial",
"transcript.final",
"error",
"session.closed"
]
}
}
}