Request parameters and response fields for the non-realtime speech synthesis (Qwen-TTS) API.
Request body |
The |
modelstring(required)The model name. For details, see Supported models. | |
inputobject(required)Input parameters.
Properties text string (required)The text to synthesize. Supports multilingual mixed input. The maximum input length is 600 characters.voice string (required)The voice to use. See Supported system voices.language_type string (optional)The language of the synthesized audio. Defaults to Auto.
|
Response object (streaming and non-streaming formats are identical) | |
status_code integerThe HTTP status code as defined in RFC 9110. Common values:• 200: Request succeeded.• 400: Invalid request parameters.• 401: Unauthorized.• 404: Resource not found.• 500: Internal server error. | |
request_id stringA unique identifier for this request. Use it for troubleshooting. | |
code stringThe error code returned on failure. See Error codes. | |
message stringThe error message returned on failure. See Error codes. | |
outputobjectThe model output.
Properties text stringAlways null. Ignore this field.choicesstringAlways null. Ignore this field.finish_reasonstringThe generation status:
objectThe audio output from the model.
Properties url stringThe URL of the complete audio file, valid for 24 hours. In non-streaming mode, returned directly in the response. In streaming mode, only returned in the last chunk of the SSE stream (intermediate chunks do not contain this field).data stringBase64-encoded audio data. In non-streaming mode, this field is always an empty string (use url to get the complete audio file). In streaming mode, intermediate chunks contain Base64-encoded audio segments, while the last chunk returns an empty string (use url to get the complete audio).id stringA unique identifier for the audio.expires_at integerThe URL expiration time as a Unix timestamp. | |
usage objectCharacter usage for this request.
Properties output_tokens integerThe number of tokens consumed by the output audio. For the Qwen3-TTS-Flash model, this field is always 0.input_tokens integerThe number of tokens consumed by the input text. For the Qwen3-TTS-Flash model, this field is always 0.characters integerThe number of characters in the input text. Returned only by the Qwen3-TTS-Flash model. | |
request_id stringA unique identifier for this request. Use it for troubleshooting. |
Audio download and playback
Before running the examples, obtain and configure an API key and install the DashScope SDK. The Python playback example also requires PyAudio and NumPy. See the code comments for PyAudio installation instructions, and install NumPy with pip install numpy.
Download audio (Java)
You must import the Gson dependency. Add it using Maven or Gradle:
- Maven
- Gradle
Add the following to
pom.xml:Streaming playback
- Python
- Java