Skip to main content
Text-to-speech

Voice cloning

Create a custom voice from an audio sample for speech synthesis or real-time voice conversations.

Feature overview

Voice cloning supports personalized voice assistants, brand-specific announcements, and customized audio content without model training.
To create a voice from a natural language description without an audio sample, use Voice design.

Prerequisites

  • Obtain an API key and set the environment variable DASHSCOPE_API_KEY.
  • Use an API key from the region you call. The examples use the Singapore endpoint, except where a model supports voice cloning only in China North 2 (Beijing). See Regions.
  • To use the HTTP approach, install the Python HTTP library requests:
pip install requests
  • To use the Python SDK, install the DashScope SDK (version 2.0.1 or later):
# The examples in this topic are based on DashScope Python SDK 2.0 and require 2.0.1 or later
pip install -U "dashscope>=2.0.1"
  • Prepare an audio file that meets the audio requirements. Qwen-Audio-TTS, Qwen-Audio-Realtime, and CosyVoice accept a public URL or a Base64 Data URI. The examples below use the URL of the sample audio file. For local audio encoding and parameters, see the HTTP API.

Get started

Cloned voices for Qwen-Audio-TTS / Qwen-Audio-Realtime / CosyVoice are bound to their target_model at creation and cannot be used with another model. To use the same reference voice with multiple models, create a separate voice for each model.
  • Qwen-Audio-TTS / CosyVoice
  • Qwen-Audio-Realtime
Qwen-Audio-TTS and CosyVoice use the same voice creation and basic synthesis workflow. The following example uses qwen-audio-3.1-tts-plus in Singapore.
  1. Create a voice: Pass the reference audio URL (the HTTP approach also accepts a Base64 Data URI; the SDK approach uses a public URL). Set target_model to the target model and prefix to the voice name prefix.
  2. Synthesize speech: Pass the returned voice ID as voice, use the same target model, and save the synthesized audio.
  • Python SDK
  • HTTP
import os

import dashscope

client = dashscope.Client(
  # If the API key is not configured in an environment variable, replace the line below with your own API key: api_key="sk-xxx"
  api_key=os.getenv("DASHSCOPE_API_KEY"),
  # Singapore (ap-southeast-1). For another region, replace ap-southeast-1 in the URL.
  # API keys are region-specific. See https://docs.qwencloud.com/developer-guides/getting-started/regions
  base_url="https://ap-southeast-1.maas.qwencloudapi.com/api/v1",
)

target_model = "qwen-audio-3.1-tts-plus"

# Create a voice
voice = client.audio.voices.create(
  target_model=target_model,
  prefix="myvoice",
  url="https://g-adoc.alcasset.com/media/maas_docs/sfm/en/audios/6a4b3c2d1e0f9198.wav",
)
voice_id = voice.voice_id
print(f"voice_id: {voice_id}")

# Synthesize speech with the bound model and the returned voice ID
audio = client.audio.tts.synthesize(
  "The weather is pleasant today. Enjoy a walk outside and have a wonderful day.",
  model=target_model,
  voice=voice_id,
  format="wav",
  sample_rate=24000,
)
with open("output.wav", "wb") as f:
  f.write(audio)
The example saves the synthesized audio to output.wav. Save the printed voice ID for later use.
For more voice cloning parameters and examples, see the HTTP API, Python SDK, and Java SDK. To use a cloned voice for speech synthesis or real-time voice conversations, see:

Audio requirements

Input audio quality affects voice similarity and naturalness. Follow the target model’s specifications and the recording tips below to reduce noise, reverberation, and other speakers’ voices.
ItemRequirement
FormatsWAV (16-bit), MP3, M4A
Duration10–20 seconds recommended; no more than 60 seconds.
File size≤ 10 MB
Sample rate≥ 16 kHz
ChannelsMono or stereo. Only the first channel of stereo audio is processed, and it must contain valid speech.
ContentAt least 5 seconds of continuous, clear reading, with only short pauses (≤ 2 seconds) elsewhere. Avoid background music, environmental noise, and other speakers. Use speech at a normal pace, rather than songs or singing recordings.
Supported languages
  • Qwen-Audio-TTS / Qwen-Audio-Realtime: Chinese (Mandarin, Cantonese, Chongqing, Northeastern, Gansu, Guizhou, Zhejiang, Hebei, Henan, Hubei, Hunan, Jiangxi, Ningbo, Ningxia, Qingdao, Shaanxi, Shanxi, Shandong, Shanghai, Sichuan, and Yunnan dialects), English, Japanese, Korean, Russian, French, German, Portuguese, Thai, Indonesian, Vietnamese, Spanish, Italian, Malaysian, Filipino, and Arabic
  • CosyVoice: Supported reference audio languages vary by the target model that uses the voice.
  • cosyvoice-v3.5-plus, cosyvoice-v3.5-flash (China North 2 (Beijing) only), cosyvoice-v3-flash: Chinese (Mandarin, Cantonese, Northeastern, Gansu, Guizhou, Henan, Hubei, Jiangxi, Southern Min, Ningxia, Shanxi, Shaanxi, Shandong, Shanghai, Sichuan, Tianjin, and Yunnan dialects), English, French, German, Japanese, Korean, Russian, Portuguese, Thai, Indonesian, and Vietnamese
  • cosyvoice-v3-plus: Chinese (Mandarin, Cantonese, Northeastern, Gansu, Guizhou, Henan, Hubei, Jiangxi, Southern Min, Ningxia, Shanxi, Shaanxi, Shandong, Shanghai, Sichuan, Tianjin, and Yunnan dialects), English, French, German, Japanese, Korean, and Russian
  • cosyvoice-v2 (China North 2 (Beijing) only): Chinese (Mandarin) and English
Clear, natural recordings help produce high-quality reference audio and preserve voice characteristics. Before recording, review the recording and operation tips below.
Recording equipment You can use a smartphone, digital voice recorder, or professional recording device. We recommend a device that supports high sample rate recording (≥ 24 kHz) to meet the audio requirements.Recording environment Location
  • Record in a small, enclosed space of 10 square meters or less.
  • Prioritize rooms with sound-absorbing materials such as acoustic foam, carpets, or curtains.
  • Avoid open halls, conference rooms, classrooms, and other high-reverberation spaces.
Noise control
  • External noise: Close doors and windows to avoid traffic, construction, and other disturbances.
  • Internal noise: Turn off air conditioners, fans, fluorescent lamp ballasts, and other equipment. You can record the ambient sound on your phone and play it back at high volume to identify potential noise sources.
Reverberation control
  • Reverberation causes sound to become blurry and reduces clarity.
  • Reduce reflections from smooth surfaces: close curtains, open wardrobe doors, and drape clothing or blankets over tables and cabinets.
  • Use irregular objects (such as bookshelves and upholstered furniture) to create diffuse reflections.
Recording script
  • There are no specific content restrictions. We recommend matching the content to your target use case.
  • Avoid short phrases (such as "hello" or "yes"). Use complete sentences.
  • Maintain semantic coherence and avoid frequent pauses while reading (at least 3 continuous seconds without interruption is recommended).
  • Maintain a consistent speaking speed throughout. Avoid speaking too fast at the beginning or end, which can cause stuttering during synthesis.
  • Include appropriate emotional expression (such as warmth, friendliness, or seriousness). Avoid mechanical reading.
  • Do not include sensitive content (such as political, pornographic, or violent material). This will cause cloning to fail.
Best practices Using a typical bedroom as an example, after completing noise and reverberation control:
  1. Familiarize yourself with the script beforehand, set a character tone, and deliver naturally.
  2. Maintain approximately 10 cm distance from the recording device to avoid plosive distortion or weak signal.

Voice management

Qwen-Audio-TTS, Qwen-Audio-Realtime, and CosyVoice share the same voice query, update, and deletion APIs. For interfaces and parameters, see the Voice cloning HTTP API reference.
  • List voices: View existing custom voices under your account.
  • Query voice details: View information such as creation time and the bound model.
  • Update a voice: Replace the reference audio while retaining the existing voice ID.
  • Delete a voice: Delete unused voices to free up quota.
Created voices remain valid by default. Save the voice ID and query the voice when needed to check its availability.

Supported models

Use a QwenCloud API key from the region you call. The models that support voice cloning differ by region.
  • Singapore
  • China North 2 (Beijing)
  • Qwen-Audio-TTS: qwen-audio-3.1-tts-plus, qwen-audio-3.1-tts-flash, qwen-audio-3.0-tts-plus, qwen-audio-3.0-tts-flash
  • CosyVoice: cosyvoice-v3-plus, cosyvoice-v3-flash

Quotas and limits

  • Voice count: Each QwenCloud account can have up to 1,000 custom voices in total. Voice cloning and voice design share this account quota across models.
  • New voice cloning or voice design creation requests fail when the quota is reached. Delete unused voices to free up quota before creating another voice.

Billing

  • Qwen-Audio-TTS / Qwen-Audio-Realtime / CosyVoice: Voice creation is free. Speech synthesis and real-time conversations using cloned voices are billed according to the target model. See Model pricing.