General-Purpose Speech Multitask Engine
Description
General-purpose speech multitask engine.
Version
1.0
Media Requirements
Supported audio formats: WAV, M4A, MP4, MP3, AAC, and others.
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_engine/481991
Task type (`task_type`): formulaMethod
POST
Content-Type: application/json
Authentication
Request Parameters
| Required | Parameter | Type | Description |
|---|---|---|---|
| Required | task | String | /v1/ai_audio_engine/481991 |
| Required | task_type | String | formula |
| Required | init_images | Object[] | Multimedia files |
| Required | params | String | Inference parameters |
| Optional | sync_timeout | Int | Default: 30. Synchronous timeout. If the API times out, status is 9; use the Task Query API to retrieve the result. |
The structure of each multimedia item in init_images is described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Required | url | String | Audio URL or base64 data |
| Required | profile | object | Audio attribute information |
The profile object is described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Required | media_profiles | object | Audio attribute information |
| Required | version | string | Fixed value: v1 |
The fields in media_profiles are described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Required | media_data_type | String | url indicates a URL; the corresponding audio type indicates base64 data. |
params is a JSON string whose decoded structure is described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Optional | rsp_media_type | String | Default: url |
| Required | parameter | object | Inference parameters |
The fields in parameter are described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Required | task_type | String | Task type. Supported values are listed below. |
Supported task_type values:
| Value | Description | Dependencies |
|---|---|---|
| lufs | Retrieve audio loudness | - |
| trans_audio | Transcribe and translate audio; return the translation and transcription | - |
| ducking | Vocal-ducking keyframes | - |
| train | Train and save a voice profile | ai-audio-timbre, ai-audio-spliter, ai-audio-asr |
| synth | Generate audio using an existing voice profile | ai-audio-timbre, ai-audio-spliter, ai-audio-asr |
| synth_once | Clone and generate once without saving the voice profile | ai-audio-timbre, ai-audio-spliter, ai-audio-asr |
| edit | Voice editing | ai-audio-timbre, ai-audio-spliter, ai-audio-asr |
| trans | Translate and generate using an existing voice profile | ai-audio-timbre, ai-audio-spliter, ai-audio-asr |
| trans_once | Extract a voice profile and translate audio in real time | ai-audio-timbre, ai-audio-spliter, ai-audio-asr |
| conversion | Voice conversion | ai-audio-spliter, ai-audio-conversion |
Detailed parameters for each task_type:
1. lufsr (section name in the source document; the task_type value is lufs, which retrieves audio loudness)
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
2. trans_audio (speech transcription and translation)
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | from | String | Source language |
| Yes | to | String | Target language |
| Yes | client_id | Int | Application client ID |
| No | asr_from | String | ASR provider; default: tencent |
| No | trans_type | String | Translation provider; default: tencent |
| No | energy_threshold | Double | Audio RMS threshold; default: 0, which skips task processing |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
3. ducking (vocal-ducking keyframes)
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
4. train (voice training and voice-profile storage)
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | prompt_lang | String | Language of the input audio. The default is zh in China and en outside China; pass en for English. |
| No | model_name | String | Supported values: qwen, index_tts2. The production model is index_tts2. |
| No | version | String | Model version. Currently supports v1, v2, and v3; default: v1. |
| No | train_limit | Float | Training segment length in seconds; default: 10s. Set to 0 to extract features from the entire input audio. |
| No | spliter | Bool | True/False; whether the input requires denoising |
| No | spliter_type | String | Denoising model type |
| No | asr_text | JSON | If provided, asr_text is used by default. |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
5. synth (generation using an existing voice profile)
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | spk_id | String | spk_id produced by model training |
| Yes | text | String | Text to synthesize |
| No | sp_speed | Float | Speed multiplier for output-audio sp; default: 1.0 |
| No | speed | Float | Output-audio speed multiplier; default: 1.0. To double the speed, pass 1/2 = 0.5. |
| No | duration | Float | Desired output-audio duration; default: 0, which preserves the duration generated by the model |
| No | use_ssml | Bool | True/False; whether to enable SSML; default: True |
| No | gen_lang | String | Output-audio language; supports zh and en; default: zh |
| No | gen_size | Int | Synthesize audio in batches; number of characters per batch |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
6. synth_once (one-time cloning and generation without saving the voice profile)
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | text | String | Text to synthesize |
| No | sp_speed | Float | Speed multiplier for output-audio sp; default: 1.0 |
| No | speed | Float | Output-audio speed multiplier; default: 1.0 |
| No | duration | Float | Desired output-audio duration; default: 0, which preserves the duration generated by the model |
| No | use_ssml | Bool | True/False; whether to enable SSML; default: True |
| No | prompt_lang | String | Language of the input audio. The default is zh in China and en outside China; pass en for English. |
| No | gen_lang | String | Output-audio language; supports zh and en; default: zh |
| No | gen_size | Int | Synthesize audio in batches; number of characters per batch |
| No | model_name | String | Supported values: qwen, index_tts2. The production model is index_tts2. |
| No | version | String | Model version. Currently supports v1, v2, and v3; default: v1. |
| No | train_limit | Float | Training segment length in seconds; default: 10s. Set to 0 to extract features from the entire input audio. |
| No | spliter | Bool | True/False; whether the input requires denoising |
| No | spliter_type | String | Denoising model type |
| No | asr_text | JSON | If provided, asr_text is used; otherwise the internal ASR service is invoked. |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
| No | emo_control_method | int | Emotion-control method; default: 0. 0: emotion from reference audio; 1: manual emotion vector; 2: independent emotion reference audio. See below. |
| No | emo_vec | float[] | Eight-dimensional manual emotion vector; required when emo_control_method=1 |
| No | emo_ref_path | String | Emotion-reference audio URL; required when emo_control_method=2 |
| No | emo_weight | float | Emotion-reference audio weight; optional when emo_control_method=2; default: 1.0; recommended range: 0.0–1.6 |
Emotion Control
emo_control_method controls the emotion source for synthesized audio and supports the following three modes:
| Value | Mode | Description | Additional parameters |
|---|---|---|---|
| 0 | Reference-audio emotion (default) | Extract emotion from the voice reference audio uploaded in init_images | None |
| 1 | Manual emotion vector | Precisely control emotion intensity with an eight-dimensional vector | emo_vec (required) |
| 2 | Independent emotion reference audio | Use another audio clip to control emotion while retaining the voice from the reference audio | emo_ref_path (required), emo_weight (optional) |
Order of the eight dimensions in emo_vec:
[happiness, anger, sadness, fear, disgust, depression, surprise, calmness]
Constraints:
emo_vecmust be a numeric array of length 8.- The sum of the eight weights must not exceed 1.5.
- If
emo_control_methodis omitted, it defaults to0, meaning the emotion is extracted from the voice reference audio.
7. edit (voice editing)
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | text | String | Text to synthesize |
| Yes | start_time | Float | Start time of the audio segment to replace (milliseconds) |
| Yes | end_time | Float | End time of the audio segment to replace (milliseconds) |
| No | sp_speed | Float | Speed multiplier for output-audio sp; default: 1.0 |
| No | speed | Float | Output-audio speed multiplier; default: 1.0 |
| No | duration | Float | Desired output-audio duration; default: 0, which preserves the duration generated by the model |
| No | use_ssml | Bool | True/False; whether to enable SSML; default: True |
| No | prompt_lang | String | Language of the input audio. The default is zh in China and en outside China; pass en for English. |
| No | gen_lang | String | Output-audio language; supports zh and en; default: zh |
| No | gen_size | Int | Synthesize audio in batches; number of characters per batch |
| No | model_name | String | Supported value: voice_mirror. The production model is voice_mirror. |
| No | version | String | Model version. Currently supports v1, v2, and v3; default: v3. |
| No | train_limit | Float | Training segment length in seconds; default: 10s. Set to 0 to extract features from the entire input audio. |
| No | spliter | Bool | True/False; whether the input requires denoising |
| No | spliter_type | String | Denoising model type |
| No | asr_text | JSON | If provided, asr_text is used; otherwise the internal ASR service is invoked. |
| No | mix | Bool | True/False; whether to overlay background audio; default: False |
| No | single | Bool | True/False; whether to use single-speaker mode. If True, the entire audio is used to extract model features; if False, audio beginning at start_time is used. |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
8. trans (translated generation using an existing voice profile)
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | process_info | JSON Array | Synthesized-audio information containing start_time, end_time, text, and trans_text |
| Yes | spk_id | String | Existing voice-profile ID |
| Yes | from | String | Source language; default: Chinese (zh) |
| Yes | to | String | Target language; default: English (en) |
| No | use_ssml | Bool | True/False; whether to enable SSML; default: True |
| No | model_name | String | Model name |
| No | version | String | Model version |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
9. trans_once (real-time voice extraction and translation)
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | process_info | JSON Array | Synthesized-audio information containing start_time, end_time, text, and trans_text |
| No | from | String | Source language; default: Chinese (zh) |
| No | to | String | Target language; default: English (en) |
| No | use_ssml | Bool | True/False; whether to enable SSML; default: True |
| No | model_name | String | Model name |
| No | version | String | Model version |
| No | sp_speed | Float | Speed multiplier for output-audio sp; default: 1.0 |
| No | speed | Float | Output-audio speed multiplier; default: 1.0 |
| No | duration | Float | Desired output-audio duration; default: 0, which preserves the duration generated by the model |
| No | train_limit | Float | Training segment length in seconds; default: 10s. Set to 0 to extract features from the entire input audio. |
| No | spliter | Bool | True/False; whether the input requires denoising |
| No | spliter_type | String | Denoising model type |
| No | asr_text | JSON | If provided, asr_text is used; otherwise the internal ASR service is invoked. |
| No | single | Bool | True/False; whether to use single-speaker mode. If True, the entire audio is used to extract model features; if False, audio beginning at start_time is used. |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
10. conversion (voice conversion)
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | spk_id | String | Voice-profile ID (supported values: ziwei, silang, wukong, baishe) |
| No | suffix | String | Returned audio format; default: mp3. Pass wav to return WAV audio. |
| No | app | String | Caller application |
| No | uid | String | uid; pass 0 when unavailable |
| No | gid | String | gid |
Request Examples
- Voice cloning — default mode (use emotion from the reference audio)
{
"task": "/v1/ai_audio_engine/481991",
"task_type": "formula",
"init_images": [{
"url": "http://action-public.meitudata.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3",
"profile": {
"media_profiles": {
"media_data_type": "url"
},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"task_type\":\"synth_once\",\"text\":\"我是你克隆的专属声音,快来用我制作视频吧。This is the voice of your clone, please use it to create videos.\"}}",
"sync_timeout": 30
}- Voice cloning — manual emotion vector (primarily sadness)
{
"task": "/v1/ai_audio_engine/481991",
"task_type": "formula",
"init_images": [{
"url": "http://action-public.meitudata.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3",
"profile": {
"media_profiles": {
"media_data_type": "url"
},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"task_type\":\"synth_once\",\"text\":\"今天天气真不错,你怎么知道的?\",\"emo_control_method\":1,\"emo_vec\":[0,0,0.55,0,0,0,0,0]}}",
"sync_timeout": 30
}- Voice cloning — independent emotion reference audio
{
"task": "/v1/ai_audio_engine/481991",
"task_type": "formula",
"init_images": [{
"url": "http://action-public.meitudata.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3",
"profile": {
"media_profiles": {
"media_data_type": "url"
},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"task_type\":\"synth_once\",\"text\":\"今天天气真不错,你怎么知道的?\",\"emo_control_method\":2,\"emo_ref_path\":\"https://example.com/emo_ref.wav\",\"emo_weight\":0.8}}",
"sync_timeout": 30
}Response Fields
Generated results are periodically deleted. Download and save them promptly.| Field | Type | Description |
|---|---|---|
| request_id | string | Request identifier |
| trace_id | string | Trace ID |
| code | int | Business status code returned by the API. 0 indicates success; a nonzero value indicates failure. |
| error_code | int | Detailed error code (normally used with code); 0 indicates no error. |
| message | string | API message; normally "success" on success and an error description on failure. |
| tips | any | Additional tips; may be null |
| data | object | Business data |
Fields in the data object
| Field | Type | Description |
|---|---|---|
| status | int | Status: -1 task not found; 0 created; 1 processing; 2 failed; 9 timed out—use the Task Query API to retrieve the result; 10 succeeded |
| result | object | Task result information |
| progress | number | Task progress |
| predict_elapsed | int | Estimated processing time in milliseconds |
| create_time | int64 | Task creation timestamp in milliseconds |
| task_id | string | System-generated task ID that uniquely identifies the task |
| custom_task_id | string | User-defined task ID (if supplied when creating the task) |
| trace_id | string | Trace ID |
| client_info | string | Client information |
| init_images | object[]/null | Echoed input media |
Fields in the result object
| Field | Type | Description |
|---|---|---|
| id | string in the example; the source parameter table specifies int | Task ID |
| parameters | object | Task result information |
| data | object in the example; the source parameter table specifies int | The source parameter table describes predicted processing time in seconds; the response example uses a task metadata object. |
| msg | string in the example; the source parameter table specifies long | Task information |
| msg_id | string | Message ID |
Fields in the parameters object
| Field | Type | Description |
|---|---|---|
| code | int | 0 indicates a normal response; nonzero values indicate errors |
| name | String | The user parameter from the request |
| id | String | Job_ID |
| created_time | String | Task execution creation time |
| updated_time | String | Task execution completion time |
| msg | String | Task execution information |
| out_src | String | Generated audio file |
| text | String | Text to synthesize |
Response Examples
Successful Response Example
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": 10,
"result": {
"id": "t_mt1a3i5n7bca14033a-6268-46ee-823e-c968beeb5b23",
"parameters": {
"clone_ori_path": "https://deepnet-baikal.obs.cn-north-4.myhuaweicloud.com/temporary/spliter/vocals_5c0e5136-ba21-42e9-b737-820e414bb0f1.wav",
"code": 0,
"create_time": "2025-09-30 17:34:09",
"duration": 4.07,
"id": "9939fbd5-7c74-47e1-9a71-d2130719bb71",
"latency": 1.85,
"msg": "success",
"name": "0",
"out_src": "https://deepnet-baikal.obs.cn-north-4.myhuaweicloud.com/temporary/zeroshot/9939fbd5-7c74-47e1-9a71-d2130719bb71_0.wav",
"src": "https://action-public-release.obs.cn-north-4.myhuaweicloud.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3?AccessKeyId=7YW1EYVPMUCUAFBLPDIN\u0026Expires=1759311244\u0026Signature=MF5vq%2B9y357Sjn23NmjWS5SHkf4%3D",
"text": "You’re drinking energy drinks? Babe, it’s time to level up.",
"ts_info": {
},
"updated_time": "2025-09-30 17:34:11"
},
"data": {
"duration": {
"alg_process_time": 2087,
"created_timestamp": 1759224849,
"pull_timestamp": 1759224849,
"repost_time": 0,
"upload_time": 0,
"waiting_time": 78
},
"error_code": 0,
"error_msg": "success",
"extra": {
},
"media_info_list": [
],
"msg_id": "a27d3c85-adb1-44a5-79ff-r0072bef0160",
"parameter": {
"clone_ori_path": "https://deepnet-baikal.obs.cn-north-4.myhuaweicloud.com/temporary/spliter/vocals_5c0e5136-ba21-42e9-b737-820e414bb0f1.wav",
"code": 0,
"create_time": "2025-09-30 17:34:09",
"duration": 4.07,
"id": "9939fbd5-7c74-47e1-9a71-d2130719bb71",
"latency": 1.85,
"msg": "success",
"name": "0",
"out_src": "https://deepnet-baikal.obs.cn-north-4.myhuaweicloud.com/temporary/zeroshot/9939fbd5-7c74-47e1-9a71-d2130719bb71_0.wav",
"src": "https://action-public-release.obs.cn-north-4.myhuaweicloud.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3?AccessKeyId=7YW1EYVPMUCUAFBLPDIN\u0026Expires=1759311244\u0026Signature=MF5vq%2B9y357Sjn23NmjWS5SHkf4%3D",
"text": "You’re drinking energy drinks? Babe, it’s time to level up.",
"ts_info": {
},
"updated_time": "2025-09-30 17:34:11"
}
},
"msg": "success",
"msg_id": "a27d3c85-adb1-44a5-79ff-r0072bef0160"
},
"progress": 1,
"predict_elapsed": 10000,
"create_time": 1759224844659,
"task_id": "t_mt1a3i5n7bca14033a-6268-46ee-823e-c968beeb5b23",
"custom_task_id": "",
"trace_id": "e69535d2-23cd-40e3-bb27-addf15cd1457",
"client_info": "",
"init_images": null
}
}Pending Response Example
Use the Task 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": {
"id": "t_mt1a3i5n7b3da6d589-46b5-4f66-a0bb-8dd22f2a172e"
},
"progress": 0,
"predict_elapsed": 10000,
"create_time": 1759202368761,
"task_id": "t_mt1a3i5n7b3da6d589-46b5-4f66-a0bb-8dd22f2a172e",
"custom_task_id": "",
"trace_id": "9129a3a2-99c4-46ce-8731-0e100e2fbee7",
"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": "ALGO_MODEL_CRASH",
"tips": null,
"data": {
"status": 2,
"result": {
"id": "t_mt1a3i5n7be8d575cc-2ffb-4e0c-85a8-1824110e31b8",
"code": 20001,
"data": {
"duration": {
"alg_process_time": 0,
"created_timestamp": 1759201989,
"pull_timestamp": 1759201989,
"repost_time": 0,
"upload_time": 0,
"waiting_time": 0
},
"error_code": 20001,
"error_msg": "ALGO_MODEL_CRASH",
"extra": {
},
"media_info_list": [
],
"msg_id": "c1b09cb2-6e05-4d21-55ab-r007b1f21bec",
"parameter": null
},
"msg": "ALGO_MODEL_CRASH",
"msg_id": "c1b09cb2-6e05-4d21-55ab-r007b1f21bec"
},
"progress": 1,
"predict_elapsed": 10000,
"create_time": 1759201989444,
"task_id": "t_mt1a3i5n7be8d575cc-2ffb-4e0c-85a8-1824110e31b8",
"custom_task_id": "",
"trace_id": "",
"client_info": "",
"init_images": null
}
}API-Specific Error Codes and Messages
| ErrorCode | Error message | Description |
|---|
General Error Codes
See API Error Codes
SDK Examples
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": {
"task_type": "synth_once",
"text": "我是你克隆的专属声音,快来用我制作视频吧。",
},
}
payload = {
"task": "/v1/ai_audio_engine/481991",
"task_type": "formula",
"init_images": [{
"url": "http://action-public.meitudata.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3",
"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_engine/481991",
"task_type": "formula",
"init_images": [{
"url": "http://action-public.meitudata.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3",
"profile": {
"media_profiles": {"media_data_type": "url"},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"task_type\":\"synth_once\",\"text\":\"我是你克隆的专属声音,快来用我制作视频吧。\"}}",
"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' => [
'task_type' => 'synth_once',
'text' => '我是你克隆的专属声音,快来用我制作视频吧。',
],
]);
$body = json_encode([
'task' => '/v1/ai_audio_engine/481991',
'task_type' => 'formula',
'init_images' => [[
'url' => 'http://action-public.meitudata.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3',
'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_engine/481991\",\n" +
" \"task_type\": \"formula\",\n" +
" \"init_images\": [{\n" +
" \"url\": \"http://action-public.meitudata.com/voice_clone/68c12c8a20160928587d19j69h5423.mp3\",\n" +
" \"profile\": {\n" +
" \"media_profiles\": {\"media_data_type\": \"url\"},\n" +
" \"version\": \"v1\"\n" +
" }\n" +
" }],\n" +
" \"params\": \"{\\\"rsp_media_type\\\":\\\"url\\\",\\\"parameter\\\":{\\\"task_type\\\":\\\"synth_once\\\",\\\"text\\\":\\\"我是你克隆的专属声音,快来用我制作视频吧。\\\"}}\",\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);
}
}
}