Happy Pony API Get an API key →

Voice design

Pricing: Voice design

Text in, speech out, in a voice you describe in plain words ("a calm, weathered old sailor with a low, gravelly voice"). No reference recording is needed: the voice is designed from the description. One mp3 comes back (320 kb/s, 24 kHz mono). The model is MOSS-TTS VoiceGenerator; Chinese, English, Japanese and Korean text are recognised automatically.

POST https://api.happypony.io/api/v1/jobs/voice-design
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

1) Create a request

POST https://api.happypony.io/api/v1/jobs/voice-design with Content-Type: application/json.

Field Type Required Default Description
text string yes, unless image_url is given with image_url: a short line written for the character The words to speak, read exactly as written (no rewriting). Up to 2000 characters, about 2.5 minutes of speech.
voice_description string no the model's default voice How the voice should sound: gender, age, timbre, pace, emotion, accent. Up to 1000 characters. With image_url, this is an extra requirement combined with the picture.
batch_size integer no 3 How many takes to render, 1 to 8.
image_url string no A public http(s) URL of a picture of the character. A vision model works out how the main character should sound and writes the voice description, usually adding up to about 30 seconds to the create call.
seed integer no random 0 to 4294967295. The same text, description and seed give the same take; change it for another take.

Neither the text, the description nor the picture goes through the image/video content check, so voice design never answers 422 content_rejected. If the vision model cannot describe the picture, the create call answers 502 and nothing is charged.

To design the voice from a picture, send image_url instead of (or along with) voice_description. The parameters on the status and result responses then show the generated text and voice_description, plus image_url and your voice_requirements:

{
  "image_url": "https://example.com/old-sailor.png",
  "voice_description": "He has a faint Irish accent"
}

Request body:

{
  "text": "Welcome aboard. Mind the gap between the dock and the deck.",
  "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace",
  "seed": 42
}
curl -X POST https://api.happypony.io/api/v1/jobs/voice-design \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"text": "Welcome aboard. Mind the gap between the dock and the deck.", "voice_description": "A calm, weathered old sailor with a low, gravelly voice"}'

Response 202 (fields: Create response):

{
  "request_id": "48410",
  "type": "voice-design",
  "status": "IN_QUEUE",
  "credits": 2,
  "status_url": "https://api.happypony.io/api/v1/jobs/48410/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48410",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48410/cancel"
}

2) Poll for status

Poll the status_url until status is COMPLETED, FAILED or CANCELLED (fields: Status response). A short line usually finishes within half a minute of leaving the queue. A queued job can be cancelled with PUT on the cancel_url (Cancel a request).

curl https://api.happypony.io/api/v1/jobs/48410/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48410",
  "type": "voice-design",
  "status": "IN_PROGRESS",
  "created_at": "2026-11-04T10:00:00.000Z",
  "completed_at": null,
  "credits": 2,
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}

3) Fetch the result

When status is COMPLETED, fetch the response_url (common fields: Result response). The speech is under audio, not images:

curl https://api.happypony.io/api/v1/jobs/48410 -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48410",
  "type": "voice-design",
  "status": "COMPLETED",
  "created_at": "2026-11-04T10:00:00.000Z",
  "completed_at": "2026-11-04T10:00:21.000Z",
  "credits": 2,
  "audio": [{ "url": "https://…signed…", "format": "mp3" }],
  "expires_in": 259200,
  "parameters": { "text": "Welcome aboard. Mind the gap between the dock and the deck.",
                  "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace",
                  "seed": 42 },
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}
Field Type Description
audio object[] One { "url", "format" } (mp3); empty until COMPLETED.
parameters object text, voice_description (null for the default voice) and seed (null when it was random). With a picture, also image_url and voice_requirements; text and voice_description are what was rendered.

Full example

Create, poll until done, download:

curl (bash)

# Needs curl and jq. Usage: HP_KEY=hp_… ./voice.sh
JOB=$(curl -s -X POST https://api.happypony.io/api/v1/jobs/voice-design \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"text": "Welcome aboard. Mind the gap between the dock and the deck.",
       "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace"}')
echo "$JOB" | jq .
STATUS_URL=$(echo "$JOB" | jq -r .status_url)
RESPONSE_URL=$(echo "$JOB" | jq -r .response_url)

while :; do
  STATUS=$(curl -s "$STATUS_URL" -H "Authorization: Bearer $HP_KEY" | jq -r .status)
  [ "$STATUS" = IN_QUEUE ] || [ "$STATUS" = IN_PROGRESS ] || break
  sleep 5
done
echo "$STATUS"
curl -s -o voice.mp3 "$(curl -s "$RESPONSE_URL" -H "Authorization: Bearer $HP_KEY" | jq -r '.audio[0].url')"

Python

# pip install requests   |   HP_KEY=hp_… python voice.py
import os, time, requests

BASE = "https://api.happypony.io/api/v1/jobs"
H = {"Authorization": f"Bearer {os.environ['HP_KEY']}"}

job = requests.post(f"{BASE}/voice-design", headers=H, json={
    "text": "Welcome aboard. Mind the gap between the dock and the deck.",
    "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace",
    "seed": 42,
})
job.raise_for_status()
job = job.json()
print("job", job["request_id"], "costs", job["credits"], "credits")

while (s := requests.get(job["status_url"], headers=H).json())["status"] in ("IN_QUEUE", "IN_PROGRESS"):
    time.sleep(5)
result = requests.get(job["response_url"], headers=H).json()
if result["status"] != "COMPLETED":
    raise SystemExit(f"{result['status']}: {result.get('error', '')}")
with open(f"voice-{job['request_id']}.mp3", "wb") as f:
    f.write(requests.get(result["audio"][0]["url"]).content)

语音设计

价格:语音设计

输入文字,输出语音,音色由你用一句话描述(例如"一位沉稳、饱经风霜的老水手,嗓音低沉沙哑")。不需要参考录音:音色按描述直接设计。返回一个 mp3(320 kb/s,24 kHz 单声道)。模型为 MOSS-TTS VoiceGenerator,自动识别中文、英文、日文和韩文文本。

POST https://api.happypony.io/api/v1/jobs/voice-design
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

1) 创建请求

POST https://api.happypony.io/api/v1/jobs/voice-design,Content-Type: application/json。

字段 类型 必填 默认值 说明
text string 是(提供 image_url 时可省略) 提供 image_url 时:为角色写一句短台词 要朗读的文字,逐字朗读(不会改写)。最多 2000 个字符,约 2.5 分钟语音。
voice_description string 否 模型默认音色 音色描述:性别、年龄、音质、语速、情绪、口音。最多 1000 个字符。提供 image_url 时,作为与图片结合的额外要求。
batch_size integer 否 3 生成的版本数,1 到 8。
image_url string 否 角色图片的公开 http(s) URL。视觉模型判断主角的声音特点并写出音色描述,创建请求通常因此增加最多约 30 秒。
seed integer 否 随机 0 到 4294967295。相同的文字、描述和 seed 得到相同的结果;换一个 seed 得到另一版。

文字、音色描述和图片都不经过图片/视频内容审核,因此语音设计不会返回 422 content_rejected。如果视觉模型无法描述图片,创建请求返回 502,不扣积分。

要根据图片设计音色,请发送 image_url 代替(或搭配)voice_description。状态和结果响应的 parameters 会显示生成的 text 和 voice_description,以及 image_url 和你的 voice_requirements:

{
  "image_url": "https://example.com/old-sailor.png",
  "voice_description": "带一点爱尔兰口音"
}

请求体:

{
  "text": "Welcome aboard. Mind the gap between the dock and the deck.",
  "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace",
  "seed": 42
}
curl -X POST https://api.happypony.io/api/v1/jobs/voice-design \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"text": "欢迎登船。上下船时请注意脚下。", "voice_description": "一位沉稳、饱经风霜的老水手,嗓音低沉沙哑"}'

响应 202(字段见创建响应):

{
  "request_id": "48410",
  "type": "voice-design",
  "status": "IN_QUEUE",
  "credits": 2,
  "status_url": "https://api.happypony.io/api/v1/jobs/48410/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48410",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48410/cancel"
}

2) 轮询状态

轮询 status_url,直到 status 为 COMPLETED、FAILED 或 CANCELLED(字段见状态响应)。一句短台词通常在离开队列后半分钟内完成。排队中的任务可以对 cancel_url 发送 PUT 取消(取消请求)。

curl https://api.happypony.io/api/v1/jobs/48410/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48410",
  "type": "voice-design",
  "status": "IN_PROGRESS",
  "created_at": "2026-11-04T10:00:00.000Z",
  "completed_at": null,
  "credits": 2,
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}

3) 获取结果

status 为 COMPLETED 后,请求 response_url(通用字段见结果响应)。语音位于 audio 下,而不是 images:

curl https://api.happypony.io/api/v1/jobs/48410 -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48410",
  "type": "voice-design",
  "status": "COMPLETED",
  "created_at": "2026-11-04T10:00:00.000Z",
  "completed_at": "2026-11-04T10:00:21.000Z",
  "credits": 2,
  "audio": [{ "url": "https://…signed…", "format": "mp3" }],
  "expires_in": 259200,
  "parameters": { "text": "Welcome aboard. Mind the gap between the dock and the deck.",
                  "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace",
                  "seed": 42 },
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}
字段 类型 说明
audio object[] 一个 { "url", "format" }(mp3);COMPLETED 之前为空。
parameters object text、voice_description(默认音色时为 null)和 seed(随机时为 null)。 提供图片时还包含 image_url 和 voice_requirements;text 和 voice_description 为实际渲染所用的内容。

完整示例

创建、轮询直到完成、下载:

curl (bash)

# Needs curl and jq. Usage: HP_KEY=hp_… ./voice.sh
JOB=$(curl -s -X POST https://api.happypony.io/api/v1/jobs/voice-design \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"text": "Welcome aboard. Mind the gap between the dock and the deck.",
       "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace"}')
echo "$JOB" | jq .
STATUS_URL=$(echo "$JOB" | jq -r .status_url)
RESPONSE_URL=$(echo "$JOB" | jq -r .response_url)

while :; do
  STATUS=$(curl -s "$STATUS_URL" -H "Authorization: Bearer $HP_KEY" | jq -r .status)
  [ "$STATUS" = IN_QUEUE ] || [ "$STATUS" = IN_PROGRESS ] || break
  sleep 5
done
echo "$STATUS"
curl -s -o voice.mp3 "$(curl -s "$RESPONSE_URL" -H "Authorization: Bearer $HP_KEY" | jq -r '.audio[0].url')"

Python

# pip install requests   |   HP_KEY=hp_… python voice.py
import os, time, requests

BASE = "https://api.happypony.io/api/v1/jobs"
H = {"Authorization": f"Bearer {os.environ['HP_KEY']}"}

job = requests.post(f"{BASE}/voice-design", headers=H, json={
    "text": "Welcome aboard. Mind the gap between the dock and the deck.",
    "voice_description": "A calm, weathered old sailor with a low, gravelly voice and a slow pace",
    "seed": 42,
})
job.raise_for_status()
job = job.json()
print("job", job["request_id"], "costs", job["credits"], "credits")

while (s := requests.get(job["status_url"], headers=H).json())["status"] in ("IN_QUEUE", "IN_PROGRESS"):
    time.sleep(5)
result = requests.get(job["response_url"], headers=H).json()
if result["status"] != "COMPLETED":
    raise SystemExit(f"{result['status']}: {result.get('error', '')}")
with open(f"voice-{job['request_id']}.mp3", "wb") as f:
    f.write(requests.get(result["audio"][0]["url"]).content)