跳转到主要内容
POST
/
v1
/
audio
/
speech
合成语音
curl --request POST \
  --url https://api.upmore.net/v1/audio/speech \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "speech-2.8-hd",
  "input": "你好,欢迎使用语音合成服务。",
  "voice": "male-qn-qingse",
  "response_format": "mp3",
  "speed": 1,
  "metadata": {}
}
'
import requests

url = "https://api.upmore.net/v1/audio/speech"

payload = {
"model": "speech-2.8-hd",
"input": "你好,欢迎使用语音合成服务。",
"voice": "male-qn-qingse",
"response_format": "mp3",
"speed": 1,
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'speech-2.8-hd',
input: '你好,欢迎使用语音合成服务。',
voice: 'male-qn-qingse',
response_format: 'mp3',
speed: 1,
metadata: {}
})
};

fetch('https://api.upmore.net/v1/audio/speech', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.upmore.net/v1/audio/speech",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'speech-2.8-hd',
'input' => '你好,欢迎使用语音合成服务。',
'voice' => 'male-qn-qingse',
'response_format' => 'mp3',
'speed' => 1,
'metadata' => [

]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://api.upmore.net/v1/audio/speech"

payload := strings.NewReader("{\n \"model\": \"speech-2.8-hd\",\n \"input\": \"你好,欢迎使用语音合成服务。\",\n \"voice\": \"male-qn-qingse\",\n \"response_format\": \"mp3\",\n \"speed\": 1,\n \"metadata\": {}\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.upmore.net/v1/audio/speech")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"speech-2.8-hd\",\n \"input\": \"你好,欢迎使用语音合成服务。\",\n \"voice\": \"male-qn-qingse\",\n \"response_format\": \"mp3\",\n \"speed\": 1,\n \"metadata\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.upmore.net/v1/audio/speech")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"speech-2.8-hd\",\n \"input\": \"你好,欢迎使用语音合成服务。\",\n \"voice\": \"male-qn-qingse\",\n \"response_format\": \"mp3\",\n \"speed\": 1,\n \"metadata\": {}\n}"

response = http.request(request)
puts response.read_body
"<string>"
{
"error": {
"code": "<string>",
"message": "<string>"
}
}
{
"error": {
"code": "<string>",
"message": "<string>"
}
}
{
"error": {
"code": "<string>",
"message": "<string>"
}
}

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
model
enum<string>
必填

使用的语音模型。hd 系列音质优先,turbo 系列时延优先。

可用选项:
speech-2.8-hd,
speech-2.8-turbo,
speech-2.6-hd,
speech-2.6-turbo,
speech-02-hd,
speech-02-turbo,
speech-01-hd,
speech-01-turbo
示例:

"speech-2.8-hd"

input
string
必填

要合成的文本,按字符数计费。

示例:

"你好,欢迎使用语音合成服务。"

voice
string
必填

MiniMax 音色 ID,如 male-qn-qingsefemale-shaonv,会作为 voice_id 透传给上游。

示例:

"male-qn-qingse"

response_format
enum<string>
默认值:mp3

返回音频的容器格式。

可用选项:
mp3,
wav,
flac,
aac,
pcm
speed
number
默认值:1

语速倍率。

必填范围: 0.5 <= x <= 2
metadata
object

透传给上游 MiniMax 的厂商专属字段,例如 {"voice_setting": {"emotion": "happy"}, "audio_setting": {"sample_rate": 32000}, "language_boost": "Chinese"}。设为 {"output_format": "url"} 时改为 302 跳转到音频 URL 而不是直接返回字节。

响应

合成成功,响应体即音频文件。

The response is of type file.