All Products
Search
Document Center

Alibaba Cloud Model Studio:Voice cloning

Last Updated:Oct 28, 2026

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.

NoteTo 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.

  • Obtain your workspace ID and replace YOUR_WORKSPACE_ID (or {WorkspaceId} in the SDK examples) with the real value. See Regions and endpoints.

  • To use the HTTP examples, install the Python HTTP library requests:

    pip install requests
    
  • To use the Python SDK examples, install the DashScope SDK (version 2.0.1 or later):

    # The examples in this documentation are based on DashScope Python SDK 2.0; version 2.0.1 or later is required
    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; MiniMax continues to use a public URL. The examples below use the URL of the sample audio file. For local audio encoding and parameters, see the HTTP API.

Get started

NoteCloned 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-TTS and CosyVoice use the same voice creation and basic synthesis workflow. The following example uses qwen-audio-3.1-tts-plus.

  1. Create a voice: Pass the reference audio URL (the HTTP API also accepts a Base64 Data URI; the SDK examples use 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

import os

import dashscope

# The following is the configuration for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
client = dashscope.Client(
    # If you have not set an environment variable, replace the following line with your Model Studio API Key: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

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

# Create the voice.
voice = client.audio.voices.create(
    target_model=target_model,
    prefix="myvoice",
    url="https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/cosyvoice/cosyvoice-zeroshot-sample.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)

HTTP

import os
import time
import requests

workspace_id = "YOUR_WORKSPACE_ID"
target_model = "qwen-audio-3.1-tts-plus"
base_url = f"https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1"
headers = {"Authorization": f"Bearer {os.environ['DASHSCOPE_API_KEY']}"}

response = requests.post(
    f"{base_url}/services/audio/tts/customization",
    headers=headers,
    json={
        "model": "voice-enrollment",
        "input": {
            "action": "create_voice",
            "target_model": target_model,
            "prefix": "myvoice",
            "audio": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/cosyvoice/cosyvoice-zeroshot-sample.wav",
        },
    },
    timeout=60,
)
response.raise_for_status()
voice_id = response.json()["output"]["voice_id"]
print(f"voice_id: {voice_id}")

for _ in range(30):
    response = requests.post(
        f"{base_url}/services/audio/tts/customization",
        headers=headers,
        json={
            "model": "voice-enrollment",
            "input": {"action": "query_voice", "voice_id": voice_id},
        },
        timeout=60,
    )
    response.raise_for_status()
    status = response.json()["output"]["status"]
    if status == "OK":
        break
    if status != "DEPLOYING":
        raise RuntimeError(f"Voice status: {status}")
    time.sleep(1)
else:
    raise TimeoutError("Voice is not ready")

response = requests.post(
    f"{base_url}/services/audio/tts/SpeechSynthesizer",
    headers=headers,
    json={
        "model": target_model,
        "input": {
            "text": "The weather is pleasant today. Enjoy a walk outside and have a wonderful day.",
            "voice": voice_id,
            "format": "wav",
            "sample_rate": 24000,
        },
    },
    timeout=60,
)
response.raise_for_status()
audio_url = response.json()["output"]["audio"]["url"]
audio_response = requests.get(audio_url, timeout=60)
audio_response.raise_for_status()
with open("output.wav", "wb") as f:
    f.write(audio_response.content)

The example saves the synthesized audio to output.wav. Save the printed voice ID for later use.

Qwen-Audio-Realtime

Cloned voices for Qwen-Audio-Realtime customize the response voice in real-time voice conversations. The following example creates a voice for qwen-audio-3.1-realtime-plus.

Python SDK

import os

import dashscope

# The following is the configuration for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
client = dashscope.Client(
    # If you have not set an environment variable, replace the following line with your Model Studio API Key: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

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

# Create the voice.
voice = client.audio.voices.create(
    target_model=target_model,
    prefix="myvoice",
    url="https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/cosyvoice/cosyvoice-zeroshot-sample.wav",
)
print(f"voice_id: {voice.voice_id}")

HTTP

import os
import time
import requests

workspace_id = "YOUR_WORKSPACE_ID"
target_model = "qwen-audio-3.1-realtime-plus"
base_url = f"https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1"
headers = {"Authorization": f"Bearer {os.environ['DASHSCOPE_API_KEY']}"}

response = requests.post(
    f"{base_url}/services/audio/tts/customization",
    headers=headers,
    json={
        "model": "voice-enrollment",
        "input": {
            "action": "create_voice",
            "target_model": target_model,
            "prefix": "myvoice",
            "audio": "https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/cosyvoice/cosyvoice-zeroshot-sample.wav",
        },
    },
    timeout=60,
)
response.raise_for_status()
voice_id = response.json()["output"]["voice_id"]
print(f"voice_id: {voice_id}")

for _ in range(30):
    response = requests.post(
        f"{base_url}/services/audio/tts/customization",
        headers=headers,
        json={
            "model": "voice-enrollment",
            "input": {"action": "query_voice", "voice_id": voice_id},
        },
        timeout=60,
    )
    response.raise_for_status()
    status = response.json()["output"]["status"]
    if status == "OK":
        break
    if status != "DEPLOYING":
        raise RuntimeError(f"Voice status: {status}")
    time.sleep(1)
else:
    raise TimeoutError("Voice is not ready")

After connecting to the real-time voice conversation service, set session.voice to the returned voice ID in the first session.update event. Replace VOICE_ID below with that ID. The session model must match the target_model used to create the voice.

{
    "type": "session.update",
    "session": {
        "voice": "VOICE_ID"
    }
}

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

Formats

WAV (16-bit), MP3, M4A

Duration

10–20 seconds recommended; no more than 60 seconds.

File size

≤ 10 MB

Sample rate

≥ 16 kHz

Channels

Mono or stereo. Only the first channel of stereo audio is processed, and it must contain valid speech.

Content

At 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.

Click to view supported languages by CosyVoice model

  • cosyvoice-v3.5-plus, cosyvoice-v3.5-flash, 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: 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.

Click to view recording and operation tips

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

China (Beijing)

Use an API key for this region to call the following models:

  • 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

  • Qwen-Audio-Realtime: qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, qwen-audio-3.0-realtime-flash

  • CosyVoice: cosyvoice-v3.5-plus, cosyvoice-v3.5-flash, cosyvoice-v3-plus, cosyvoice-v3-flash, cosyvoice-v2

Singapore

Use an API key for this region to call the following models:

  • 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 Alibaba Cloud Model Studio account can have up to 1,000 custom voices in total. Voice cloning and voice design share this account quota across models.

    Note

    • 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.