A
API 文档

Amphion 开放平台 API 文档Amphion Platform API Documentation

Amphion 开放平台提供高质量的语音 AI 服务,包括 TTS(文本转语音)SED(语音情感检测)。所有接口通过 RESTful API 提供,使用 API Key 进行身份验证。Amphion Platform provides high-quality voice AI services, including TTS (Text-to-Speech) and SED (Speech Emotion Detection). All endpoints are RESTful APIs authenticated via API Key.

认证方式Authentication

所有 API 请求需携带有效的 API Key。支持以下两种方式:All API requests require a valid API Key. Two methods are supported:

方式一:X-API-Key HeaderMethod 1: X-API-Key Header
X-API-Key: sk-your-api-key-here
方式二:Authorization BearerMethod 2: Authorization Bearer
Authorization: Bearer sk-your-api-key-here

你可以在 控制台 → API Keys 页面创建和管理你的密钥。You can create and manage your keys in Console → API Keys.

Base URL

https://api.amphion.example.com

API 网关默认端口为 8888。实际地址请以部署环境为准。API gateway default port is 8888. Actual address depends on deployment.

POST TTS — 文本转语音TTS — Text-to-Speech

将文本转换为高质量语音,基于 Qwen3-TTS 模型。Convert text to high-quality speech using Qwen3-TTS model.

端点Endpoint

POST /tts/v1/audio/speech

请求参数Request Parameters

参数Parameter 类型Type 必填Required 说明Description
model string Yes 模型名称,如 Qwen3-TTSModel name, e.g. Qwen3-TTS
input string Yes 要转换的文本内容Text content to convert
voice string No 语音角色 / 说话人 IDVoice character / speaker ID
response_format string No 输出格式:mp3 / wav,默认 mp3Output format: mp3 / wav, default mp3

响应Response

成功时返回音频二进制流,Content-Type 为 audio/mpegaudio/wavOn success, returns audio binary stream with Content-Type audio/mpeg or audio/wav.

代码示例Code Examples

curl -X POST https://api.amphion.example.com/tts/v1/audio/speech \
  -H "X-API-Key: sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen3-TTS",
    "input": "你好,欢迎使用 Amphion 开放平台。",
    "voice": "default"
  }' \
  --output output.mp3
import requests

resp = requests.post(
    "https://api.amphion.example.com/tts/v1/audio/speech",
    headers={"X-API-Key": "sk-your-api-key"},
    json={
        "model": "Qwen3-TTS",
        "input": "你好,欢迎使用 Amphion 开放平台。",
        "voice": "default",
    },
)

with open("output.mp3", "wb") as f:
    f.write(resp.content)

print(f"Status: {resp.status_code}, Size: {len(resp.content)} bytes")
const fs = require("fs");

const resp = await fetch("https://api.amphion.example.com/tts/v1/audio/speech", {
  method: "POST",
  headers: {
    "X-API-Key": "sk-your-api-key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "Qwen3-TTS",
    input: "你好,欢迎使用 Amphion 开放平台。",
    voice: "default",
  }),
});

const buf = Buffer.from(await resp.arrayBuffer());
fs.writeFileSync("output.mp3", buf);
console.log(`Status: ${resp.status}, Size: ${buf.length} bytes`);

POST SED — 语音情感检测SED — Speech Emotion Detection

分析音频中的情感成分,基于 Zipformer 语音情感检测模型。Analyze emotional components in audio using Zipformer Speech Emotion Detection model.

端点Endpoint

POST /sed/v1/audio/analyze

请求参数Request Parameters

multipart/form-data 上传音频文件。Upload audio file as multipart/form-data.

参数Parameter 类型Type 必填Required 说明Description
file file Yes 音频文件(支持 wav / mp3 / flac)Audio file (supports wav / mp3 / flac)
model string No 模型名称,默认 Zipformer-SEDModel name, default Zipformer-SED

响应示例Response Example

{
  "emotions": [
    { "label": "happy",   "score": 0.82 },
    { "label": "neutral", "score": 0.12 },
    { "label": "sad",     "score": 0.04 },
    { "label": "angry",   "score": 0.02 }
  ],
  "duration_seconds": 3.45,
  "model": "Zipformer-SED"
}

代码示例Code Examples

curl -X POST https://api.amphion.example.com/sed/v1/audio/analyze \
  -H "X-API-Key: sk-your-api-key" \
  -F "file=@audio.wav"
import requests

with open("audio.wav", "rb") as f:
    resp = requests.post(
        "https://api.amphion.example.com/sed/v1/audio/analyze",
        headers={"X-API-Key": "sk-your-api-key"},
        files={"file": ("audio.wav", f, "audio/wav")},
    )

data = resp.json()
for emo in data["emotions"]:
    print(f"{emo['label']}: {emo['score']:.2%}")
const fs = require("fs");
const FormData = require("form-data");

const form = new FormData();
form.append("file", fs.createReadStream("audio.wav"));

const resp = await fetch("https://api.amphion.example.com/sed/v1/audio/analyze", {
  method: "POST",
  headers: { "X-API-Key": "sk-your-api-key", ...form.getHeaders() },
  body: form,
});

const data = await resp.json();
data.emotions.forEach(e => console.log(`${e.label}: ${(e.score * 100).toFixed(1)}%`));

错误码说明Error Codes

当请求失败时,API 返回 JSON 格式的错误响应。When a request fails, the API returns a JSON error response.

{
  "detail": "Missing API key. Provide X-API-Key header or Authorization: Bearer <key>."
}
HTTP 状态码HTTP Status 含义Meaning 常见原因Common Cause
400 Bad Request 请求参数缺失或格式错误Missing or malformed request parameters
401 Unauthorized 缺少 API Key 或 Key 无效Missing API Key or invalid Key
403 Forbidden API Key 已过期/被吊销,或账户被停用、余额不足API Key expired/revoked, or account suspended, insufficient balance
429 Too Many Requests 请求频率超限,请稍后重试Rate limit exceeded, please retry later
500 Internal Server Error 服务端内部错误Internal server error
502 / 503 Service Unavailable 上游模型服务暂时不可用Upstream model service temporarily unavailable

计费说明Pricing

API 调用按请求数计费,每次成功调用从账户余额中扣除相应费用。API calls are billed per request. Each successful call deducts from your balance.

服务Service 单价(每次调用)Price (per call)
TTS 语音合成TTS Text-to-Speech ¥0.0100
SED 语音情感检测SED Speech Emotion Detection ¥0.0050

新用户福利New User Bonus

注册即赠送 ¥100 体验金,可立即开始使用所有 API 服务。Sign up to receive ¥100 in free credits to start using all API services.

Amphion 开放平台 © 2026 · 返回控制台