SenseAudio TTS Quick
Zero-config speech synthesis. User gives text, you produce an mp3 file — no API knowledge required.
Voice Selection
Default voice: male_0004_a (儒雅道长, neutral).
Map natural-language requests to voice IDs before calling the API:
| User says | voice_id |
|---|
| 女声 / 女生 / 女的 | INLINECODE1 (温柔御姐) |
| 温柔御姐 |
female_0006_a |
| 嗲嗲 / 台妹 |
female_0033_a |
| 撒娇 |
female_0033_c |
| 低落 / 难过 / 悲伤 |
female_0033_d |
| 委屈 |
female_0033_e |
| 生气 / 愤怒 |
female_0033_f |
| 开心 / 高兴 / 活泼 |
female_0033_b |
| 傲娇 |
female_0027_f |
| 病娇 |
female_0027_c |
| 妩媚 / 性感 |
female_0027_e |
| 男声 / 男生 |
male_0004_a |
| 沙哑 / 深情 |
male_0018_a |
| 撒娇青年 |
male_0023_a |
| 乐观 / 少年 |
male_0026_a |
| 儿童 / 小孩 / 萌娃 |
child_0001_b |
If the user names a voice not in this table, use male_0004_a and note the fallback.
Long Text Pacing
For text longer than 100 characters, insert <break time="300"/> after each 。 ! ? to improve natural rhythm:
CODEBLOCK0
Do not insert breaks inside quoted speech or after mid-sentence punctuation like ,.
API Call
CODEBLOCK1
Check base_resp.status_code == 0 before decoding. On error, show base_resp.status_msg.
Output
After generating the file:
- 1. Save as a descriptive filename, e.g.
speech_<timestamp>.mp3 or based on the first few words of the text. - Report:
- File path
- Audio duration:
jq '.extra_info.audio_length' response.json (ms → seconds)
- Character count:
jq '.extra_info.usage_characters' response.json
- Voice used
Example output:
CODEBLOCK2
Error Handling
| statuscode | Likely cause | Action |
|---|
| 401 | Invalid API key | Ask user to check SENSEAUDIOAPI_KEY |
| 400 |
Text too long (>10000 chars) | Split text and generate multiple files |
| 429 | Rate limit | Wait a moment and retry once |
SenseAudio TTS 快速合成
零配置语音合成。用户提供文本,您生成一个mp3文件——无需API知识。
音色选择
默认音色:male0004a(儒雅道长,中性)。
在调用API前,将自然语言请求映射到音色ID:
| 用户描述 | 音色ID |
|---|
| 女声 / 女生 / 女的 | female0006a(温柔御姐) |
| 温柔御姐 |
female
0006a |
| 嗲嗲 / 台妹 | female
0033a |
| 撒娇 | female
0033c |
| 低落 / 难过 / 悲伤 | female
0033d |
| 委屈 | female
0033e |
| 生气 / 愤怒 | female
0033f |
| 开心 / 高兴 / 活泼 | female
0033b |
| 傲娇 | female
0027f |
| 病娇 | female
0027c |
| 妩媚 / 性感 | female
0027e |
| 男声 / 男生 | male
0004a |
| 沙哑 / 深情 | male
0018a |
| 撒娇青年 | male
0023a |
| 乐观 / 少年 | male
0026a |
| 儿童 / 小孩 / 萌娃 | child
0001b |
如果用户指定的音色不在上述表格中,则使用 male0004a 并注明已回退到默认音色。
长文本节奏处理
对于超过100个字符的文本,在每个。 ! ?后插入以改善自然节奏:
原文:今天天气很好。我们出去走走吧。
处理后:今天天气很好。我们出去走走吧。
不要在引号内的对话或句中标点如,后插入停顿。
API调用
bash
curl -s -X POST https://api.senseaudio.cn/v1/t2a_v2 \
-H Authorization: Bearer $SENSEAUDIOAPIKEY \
-H Content-Type: application/json \
-d {
model: SenseAudio-TTS-1.0,
text: ,
stream: false,
voice_setting: {
voiceid: ID>
},
audio_setting: {
format: mp3
}
} -o response.json
将十六进制音频解码为mp3
jq -r .data.audio response.json | xxd -r -p > output.mp3
在解码前检查 baseresp.statuscode == 0。如果出错,显示 baseresp.statusmsg。
输出
生成文件后:
- 1. 保存为描述性文件名,例如 speech_<时间戳>.mp3 或基于文本的前几个词命名。
- 报告:
- 文件路径
- 音频时长:jq .extra
info.audiolength response.json(毫秒 → 秒)
- 字符数:jq .extra
info.usagecharacters response.json
- 使用的音色
示例输出:
生成完成:speech_20240315.mp3
音色:温柔御姐 (female0006a)
时长:4.2 秒
字数:38 字
错误处理
| 状态码 | 可能原因 | 处理方式 |
|---|
| 401 | API密钥无效 | 请用户检查SENSEAUDIOAPIKEY |
| 400 |
文本过长(超过10000字符) | 拆分文本并生成多个文件 |
| 429 | 频率限制 | 稍等片刻后重试一次 |