QWEN Voice Cloning

Description

This API provides both voice cloning and voice design capabilities, generating speech in a target voice from a small audio sample or a text instruction (Text-to-Speech).

  • Voice cloning: Clones a voice from a user-provided WAV audio sample, then synthesizes the specified text in the cloned voice.
  • Voice design: Requires no audio input. Describe the desired voice characteristics with instruct to create a new voice and synthesize speech directly.

params.parameter.task_type supports vocal_transformer, synth_once, and voice_design, covering four input modes.

Version

1.0

Media Requirements

The input medium for this API is audio. Voice cloning mode (vocal_transformer without instruct, or synth_once) requires an audio sample URL; WAV format is recommended. Voice design mode (vocal_transformer with instruct, or voice_design) does not require an audio sample. The request and SDK examples in this document use synth_once, which requires an audio sample.

API URL

    Production environment: https://openapi.meitu.com
    Task submission endpoint: https://openapi.meitu.com/api/v1/sdk/sync/push
    Task name (task): /v1/ai_audio_qwen_tts/491349
    Task type (task_type): formula

Method

POST

Content-Type: application/json

Authentication

Open Platform API Signing

Request Parameters

RequiredParameterTypeDescription
RequiredparamsstringAlgorithm parameters (JSON string)
Requiredinit_imagesobject[]List of media files
RequiredtaskstringFixed value: /v1/ai_audio_qwen_tts/491349
Requiredtask_typestringFixed value: formula
Optionalsync_timeoutintDefaults to 30; synchronous timeout

The init_images media file parameters are structured as follows:

RequiredParameterTypeDescription
RequiredurlstringAudio URL; no audio sample is required in voice design mode
RequiredprofileobjectAttribute information

profile attribute information:

RequiredParameterTypeDescription
Requiredmedia_profilesobjectMedia attribute information
RequiredversionstringFixed value: v1

media_profiles media attribute information:

RequiredParameterTypeDescription
Optionalmedia_data_typestringDefaults to url, indicating that the url field contains a media URL

The params inference parameters are provided as a JSON string with the following structure:

RequiredFieldTypeDescription
Optionalrsp_media_typestringDefaults to url; jpg indicates base64
RequiredparameterobjectCore algorithm parameter object

parameter algorithm parameter details:

RequiredFieldTypeDescription
OptionalappstringApplication identifier
Requiredtask_typestringAlgorithm synthesis mode: vocal_transformer, synth_once, or voice_design
RequiredtextstringTarget text to synthesize
Conditionally requiredinstructstringVoice description instruction; required for voice design mode and omitted for voice cloning mode
OptionallanguagestringSynthesis language; supported only in voice_design mode, for example Chinese
OptionaluidstringUser identifier used to associate the synthesis request with a user

The modes and their input requirements are as follows:

Modeparameter.task_typeinstructAudio Sample
Voice cloningvocal_transformerOmittedRequired
Voice cloningsynth_onceOmittedRequired
Voice designvocal_transformerRequiredNot required
Voice designvoice_designRequiredNot required

Request Example

The following example uses synth_once voice cloning mode:

{
  "task": "/v1/ai_audio_qwen_tts/491349",
  "task_type": "formula",
  "init_images": [
    {
      "url": "https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA==/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave",
      "profile": {
        "media_profiles": {
          "media_data_type": "url"
        },
        "version": "v1"
      }
    }
  ],
  "params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"app\":\"your-app\",\"task_type\":\"synth_once\",\"text\":\"要合成的完整句子。\",\"uid\":\"user-1\"}}",
  "sync_timeout": 30
}

Response Fields

Generated results are periodically deleted. Download and save them promptly.
FieldTypeDescription
request_idstringRequest identifier
trace_idstringTrace identifier
codeintBusiness status code; 0 indicates that the request was accepted successfully
error_codeintError code; 0 on success
messagestringBusiness message
tipsanyAdditional information
dataobjectTask status and algorithm result

Fields in data:

FieldTypeDescription
statusintStatus code: -1 task not found; 0 created; 1 running; 2 failed; 9 timed out—use the Query API; 10 succeeded
resultobjectAlgorithm result
progressnumberTask progress in the range 0–1; 1 indicates completion
predict_elapsedintEstimated processing time, in milliseconds
create_timeint64Creation timestamp, in milliseconds
task_idstringTask ID
custom_task_idstringClient-defined task ID
trace_idstringTrace identifier
client_infostringClient information
init_imagesobject[]/nullEcho of the input media

Fields in result:

FieldTypeDescription
idstringUnique task identifier
parametersobjectEcho of the algorithm processing parameters, including the synthesized audio result
dataobjectDetailed data returned by the algorithm
msgstringResponse message
msg_idstringMessage ID
mtlab_resobjectUnderlying algorithm result

The synthesized audio URL is returned in parameters.out_src or result.data.parameter.out_src; the response does not contain urls or images fields.

Fields in result.data:

FieldTypeDescription
durationobjectTiming statistics for each processing stage
error_codenumberAlgorithm error code; 0 indicates success
error_msgstringAlgorithm error message
extraobjectExtended fields
media_info_listarrayMedia information list; an empty array in this response
msg_idstringMessage ID
parameterobjectEcho of the parameters

Fields in duration:

FieldTypeDescription
alg_process_timenumberAlgorithm processing time, in milliseconds
created_timestampnumberTask creation timestamp, in seconds
pull_timestampnumberResource retrieval timestamp, in seconds
repost_timenumberRetry time
upload_timenumberUpload time, in milliseconds
waiting_timenumberQueue waiting time, in milliseconds

Fields in parameters / parameter:

FieldTypeDescription
codenumberSynthesis result code; 0 indicates success
msgstringSynthesis result message
idstringUnique identifier for this synthesis request
srcstringFull URL of the source audio used for cloning
clone_ori_pathstringPath of the source audio used for cloning
out_srcstringOutput URL of the synthesized audio; it can be accessed or downloaded directly
textstringTarget text synthesized
durationnumberDuration of the synthesized audio, in seconds
namestringUser identifier corresponding to uid in the request
create_timestringSynthesis task creation time in yyyy-MM-dd HH:mm:ss format
updated_timestringSynthesis task update time in yyyy-MM-dd HH:mm:ss format
latencystringSynthesis latency in seconds, for example 14.65
ts_infoobjectTimestamp information (reserved field)

Fields in mtlab_res:

FieldTypeDescription
ErrorCodenumberUnderlying error code
ErrorMsgstringUnderlying error message
error_codenumberError code (compatibility field)
error_msgstringError message (compatibility field)
media_info_listarray/nullMedia information list
msg_idstringMessage ID
parameterobject/nullParameter information

Response Examples

Successful Response Example

{
  "request_id": "",
  "trace_id": "",
  "code": 0,
  "error_code": 0,
  "message": "success",
  "tips": null,
  "data": {
    "status": 10,
    "result": {
      "id": "t_mt1a3i5n7b04a2e6e0-f8bc-4051-a5aa-af5b4604497c",
      "parameters": {
        "clone_ori_path": "https://obs-open-platform.obs.cn-north-4.myhuaweicloud.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA%3D%3D/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave?AccessKeyId=QLFrateOfrxEG2sqhJ0Y&Expires=1779539428&Signature=TAqSFs0%2BPZP5SW%2B8JZ6YlapXUwc%3D",
        "code": 0,
        "create_time": "2026-05-22 20:30:28",
        "duration": 1.76,
        "id": "5ce81565-bdbc-41df-8782-3e2bca88f661",
        "latency": "14.65",
        "msg": "success",
        "name": "user-1",
        "out_src": "https://mt-aiaudio-release.oss-cn-beijing.aliyuncs.com/temporary/zeroshot/5ce81565-bdbc-41df-8782-3e2bca88f661_0.wav",
        "src": "https://obs-open-platform.obs.cn-north-4.myhuaweicloud.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA%3D%3D/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave?AccessKeyId=QLFrateOfrxEG2sqhJ0Y&Expires=1779539428&Signature=TAqSFs0%2BPZP5SW%2B8JZ6YlapXUwc%3D",
        "text": "要合成的完整句子。",
        "ts_info": {},
        "updated_time": "2026-05-22 20:30:43"
      },
      "data": {
        "duration": {
          "alg_process_time": 14856,
          "created_timestamp": 1779453028,
          "pull_timestamp": 1779453028,
          "repost_time": 0,
          "upload_time": 0,
          "waiting_time": 30
        },
        "error_code": 0,
        "error_msg": "success",
        "extra": {},
        "media_info_list": [],
        "msg_id": "dfa635ba-cad8-41b0-7709-r00924be2f00",
        "parameter": {
          "clone_ori_path": "https://obs-open-platform.obs.cn-north-4.myhuaweicloud.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA%3D%3D/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave?AccessKeyId=QLFrateOfrxEG2sqhJ0Y&Expires=1779539428&Signature=TAqSFs0%2BPZP5SW%2B8JZ6YlapXUwc%3D",
          "code": 0,
          "create_time": "2026-05-22 20:30:28",
          "duration": 1.76,
          "id": "5ce81565-bdbc-41df-8782-3e2bca88f661",
          "latency": "14.65",
          "msg": "success",
          "name": "user-1",
          "out_src": "https://mt-aiaudio-release.oss-cn-beijing.aliyuncs.com/temporary/zeroshot/5ce81565-bdbc-41df-8782-3e2bca88f661_0.wav",
          "src": "https://obs-open-platform.obs.cn-north-4.myhuaweicloud.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA%3D%3D/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave?AccessKeyId=QLFrateOfrxEG2sqhJ0Y&Expires=1779539428&Signature=TAqSFs0%2BPZP5SW%2B8JZ6YlapXUwc%3D",
          "text": "要合成的完整句子。",
          "ts_info": {},
          "updated_time": "2026-05-22 20:30:43"
        }
      },
      "msg": "success",
      "msg_id": "dfa635ba-cad8-41b0-7709-r00924be2f00",
      "mtlab_res": {
        "ErrorCode": 0,
        "ErrorMsg": "",
        "error_code": 0,
        "error_msg": "",
        "media_info_list": null,
        "msg_id": "dfa635ba-cad8-41b0-7709-r00924be2f00",
        "parameter": null
      }
    },
    "progress": 1,
    "predict_elapsed": 10000,
    "create_time": 1779453028327,
    "task_id": "t_mt1a3i5n7b04a2e6e0-f8bc-4051-a5aa-af5b4604497c",
    "custom_task_id": "",
    "trace_id": "",
    "client_info": "",
    "init_images": null
  }
}

Query-Required Response Example

Use the Query API to retrieve the result.

Response Status: 200

content-type: application/json; charset=utf-8

{
  "request_id": "",
  "trace_id": "",
  "code": 0,
  "error_code": 0,
  "message": "success",
  "tips": null,
  "data": {
    "status": 9,
    "result": {},
    "progress": 0,
    "predict_elapsed": 10000,
    "create_time": 1779453028327,
    "task_id": "t_mt1a3i5n7b04a2e6e0-f8bc-4051-a5aa-af5b4604497c",
    "custom_task_id": "",
    "trace_id": "",
    "client_info": "",
    "init_images": null
  }
}

Failed Response Example

Response Status: 400

content-type: application/json; charset=utf-8

{
  "request_id": "",
  "trace_id": "",
  "code": 20001,
  "error_code": 20001,
  "message": "PROCESS_ERROR",
  "tips": null,
  "data": {
    "status": 2,
    "result": {
      "error_code": 20001,
      "error_msg": "PROCESS_ERROR"
    },
    "progress": 0,
    "predict_elapsed": 0,
    "create_time": 1779453028327,
    "task_id": "t_mt1a3i5n7b04a2e6e0-f8bc-4051-a5aa-af5b4604497c",
    "custom_task_id": "",
    "trace_id": "",
    "client_info": "",
    "init_images": null
  }
}

API-specific error: 20001 (PROCESS_ERROR), indicating a processing error.

General Error Codes

See API Error Codes for details.

SDK Examples

All examples below use synth_once voice cloning mode and sign the actual request body.

Python

import json

import requests
from sign_sdk import sign

def api_call_example():
    key = "your_api_key"
    secret = "your_api_secret"
    url = "https://openapi.meitu.com/api/v1/sdk/sync/push"
    method = "POST"

    headers = {
        "Content-Type": "application/json",
        sign.HeaderHost: "openapi.meitu.com",
    }
    inner_params = {
        "rsp_media_type": "url",
        "parameter": {
            "app": "your-app",
            "task_type": "synth_once",
            "text": "要合成的完整句子。",
            "uid": "user-1",
        },
    }
    payload = {
        "task": "/v1/ai_audio_qwen_tts/491349",
        "task_type": "formula",
        "init_images": [
            {
                "url": "https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA==/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave",
                "profile": {
                    "media_profiles": {"media_data_type": "url"},
                    "version": "v1",
                },
            }
        ],
        "params": json.dumps(inner_params, ensure_ascii=False),
        "sync_timeout": 30,
    }
    body = json.dumps(payload, ensure_ascii=False)

    signer = sign.Signer(key, secret)
    signed_request = signer.sign(url, method, headers, body)
    response = requests.Session().send(signed_request)
    print(f"Status: {response.status_code}")
    print(f"Response: {response.text}")

if __name__ == "__main__":
    api_call_example()

Go

package main

import (
	"fmt"
	"io"
	"net/http"

	"github.com/mtlab/api/signer"
)

func main() {
	key := "your_api_key"
	secret := "your_api_secret"
	signObj := signer.NewSigner(key, secret)

	url := "https://openapi.meitu.com/api/v1/sdk/sync/push"
	method := http.MethodPost
	headers := make(http.Header)
	headers.Set(signer.HeaderHost, "openapi.meitu.com")
	headers.Set("Content-Type", "application/json")

	body := `{
  "task": "/v1/ai_audio_qwen_tts/491349",
  "task_type": "formula",
  "init_images": [{
    "url": "https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA==/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave",
    "profile": {
      "media_profiles": {"media_data_type": "url"},
      "version": "v1"
    }
  }],
  "params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"app\":\"your-app\",\"task_type\":\"synth_once\",\"text\":\"要合成的完整句子。\",\"uid\":\"user-1\"}}",
  "sync_timeout": 30
}`

	req, err := signObj.Sign(url, method, headers, body)
	if err != nil {
		fmt.Println("Failed to sign request:", err)
		return
	}

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		fmt.Println("Failed to send request:", err)
		return
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Read response failed:", err)
		return
	}
	fmt.Println("Response:", resp.StatusCode, string(responseBody))
}

PHP

<?php
require 'signer.php';

$key = 'your_api_key';
$secret = 'your_api_secret';
$signer = new Signer($key, $secret);

$url = 'https://openapi.meitu.com/api/v1/sdk/sync/push';
$method = 'POST';
$headers = ['Content-Type' => 'application/json'];

$innerParams = json_encode([
    'rsp_media_type' => 'url',
    'parameter' => [
        'app' => 'your-app',
        'task_type' => 'synth_once',
        'text' => '要合成的完整句子。',
        'uid' => 'user-1',
    ],
]);

$body = json_encode([
    'task' => '/v1/ai_audio_qwen_tts/491349',
    'task_type' => 'formula',
    'init_images' => [
        [
            'url' => 'https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA==/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave',
            'profile' => [
                'media_profiles' => ['media_data_type' => 'url'],
                'version' => 'v1',
            ],
        ],
    ],
    'params' => $innerParams,
    'sync_timeout' => 30,
]);

$curl = $signer->sign($url, $method, $headers, $body);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status === 0) {
    echo 'Error: ' . curl_error($curl);
} else {
    echo "Status: {$status}\n";
    echo "Response: {$response}\n";
}
curl_close($curl);
?>

Java

package com.meitu.openai.common;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) throws Exception {
        Signer signer = new Signer("your_api_key", "your_api_secret");
        String url = "https://openapi.meitu.com/api/v1/sdk/sync/push";
        String method = "POST";

        Map<String, String> headers = new HashMap<>();
        headers.put("Content-Type", "application/json");
        headers.put(Signer.HeaderHost, "openapi.meitu.com");

        String body = "{\n" +
                "  \"task\": \"/v1/ai_audio_qwen_tts/491349\",\n" +
                "  \"task_type\": \"formula\",\n" +
                "  \"init_images\": [{\n" +
                "    \"url\": \"https://obs.mtlab.meitu.com/public/EtRGxLI8ulQ43pGhuZfym9aYUD2PUbMP/MTc3NzAxMDQwMA==/bcbc891b-e6ad-417a-408d-98b3b84d3bd2.wave\",\n" +
                "    \"profile\": {\n" +
                "      \"media_profiles\": {\"media_data_type\": \"url\"},\n" +
                "      \"version\": \"v1\"\n" +
                "    }\n" +
                "  }],\n" +
                "  \"params\": \"{\\\"rsp_media_type\\\":\\\"url\\\",\\\"parameter\\\":{\\\"app\\\":\\\"your-app\\\",\\\"task_type\\\":\\\"synth_once\\\",\\\"text\\\":\\\"要合成的完整句子。\\\",\\\"uid\\\":\\\"user-1\\\"}}\",\n" +
                "  \"sync_timeout\": 30\n" +
                "}";

        Map<String, String> signedHeaders = signer.sign(url, method, headers, body);
        HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
        connection.setRequestMethod(method);
        for (Map.Entry<String, String> entry : signedHeaders.entrySet()) {
            connection.setRequestProperty(entry.getKey(), entry.getValue());
        }
        connection.setDoOutput(true);
        connection.getOutputStream().write(body.getBytes(StandardCharsets.UTF_8));

        int status = connection.getResponseCode();
        InputStream stream = status >= 400
                ? connection.getErrorStream()
                : connection.getInputStream();
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
            StringBuilder response = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                response.append(line);
            }
            System.out.println("Response: " + status + " " + response);
        }
    }
}