Audio Models
Qwen audio models for speech recognition, text-to-speech, and omni audio-language understanding.
Audio Models
QwenAPI provides audio capabilities through dedicated ASR/TTS models and the Qwen3-Omni model, which handles audio input and output alongside text and images in a single API call.
Model Overview
Speech Recognition (ASR)
Transcribe audio files or answer questions about audio content using qwen-audio-turbo:
``python
from openai import OpenAI
import base64
client = OpenAI(
api_key="YOUR_QWENAPI_KEY",
base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
)
with open("recording.mp3", "rb") as f:
audio_data = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="qwen-audio-turbo",
messages=[
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {"data": audio_data, "format": "mp3"},
},
{"type": "text", "text": "Transcribe this audio."},
],
}
],
)
print(response.choices[0].message.content)
`
Supported audio formats: MP3, WAV, FLAC, OGG, M4A. Maximum file size: 100 MB.
Text-to-Speech (TTS)
Generate natural speech from text using the /audio/speech endpoint:
`python
response = client.audio.speech.create(
model="cosyvoice-v2",
voice="alloy", # alloy, echo, fable, onyx, nova, shimmer
input="Welcome to QwenAPI. Your API key is ready.",
)
with open("output.mp3", "wb") as f:
f.write(response.content)
`
Supported output formats: MP3, WAV, PCM. Default: MP3.
Omni Audio with Qwen3-Omni
qwen3-omni-flash handles text, images, and audio in a single model. Use it when you need to combine modalities — for example, answering questions about a voice recording while also referencing an image.
`python
response = client.chat.completions.create(
model="qwen3-omni-flash",
messages=[
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {"data": audio_data, "format": "wav"},
},
{"type": "text", "text": "What language is being spoken, and what is the speaker's tone?"},
],
}
],
)
`
Audio Output from Omni
qwen3-omni-flash can also generate spoken audio responses:
`python
response = client.chat.completions.create(
model="qwen3-omni-flash",
messages=[{"role": "user", "content": "Say hello in three languages."}],
modalities=["text", "audio"],
audio={"voice": "alloy", "format": "mp3"},
)
audio_bytes = base64.b64decode(response.choices[0].message.audio.data)
with open("response.mp3", "wb") as f:
f.write(audio_bytes)
`
Pricing
Audio tokens are priced separately from text tokens:
- qwen3-omni-flash
audio input: $3.00 per 1M audio tokens - qwen3-omni-flash
text input: $0.43 per 1M tokens - TTS (cosyvoice-v2
): priced per 1K characters of input text
One minute of audio is approximately 1,500 audio tokens.
Choosing the Right Model
Use qwen-audio-turbo for pure transcription and audio Q&A at lower cost.
Use cosyvoice-v2 for TTS when you only need speech output.
Use qwen3-omni-flash` when your workflow mixes audio with text or images, or when you need the model to both understand and speak.