Grok TTS API 调用参考
71 种音色、20 种语言,支持语气标签
用一个 PopNow API 密钥,就能在自己的代码里调用 Grok TTS。下面列出要填的调用名、这个型号接受的每个输入字段、每次请求花多少积分,以及一段可以直接粘进终端运行的请求。
参数说明直接取自型号的输入 schema,暂时只有英文。
一览
- 出品方
- xAI
- 产出
- 音频
- 起价
- 2.7 积分 每 1000 字符 ($0.027)
1 积分 = 0.01 美元。任务受理时先冻结可能的最高费用,完成后按实际用量结算、向上取整到整积分,多冻的退回;失败的任务不扣积分。想在运行前知道确切数字,先调 POST /api/v1/jobs/quote。
文字转语音
xai/grok-tts/text-to-speech
价格
| 选项 | 积分 (每 1000 字符) | 美元 |
|---|---|---|
默认 | 2.7 | $0.027 |
参数
| 字段 | 类型 | 默认值 | 取值范围 | 作用 |
|---|---|---|---|---|
text必填 | string | — | 最多 15000 个字符 | The words to be spoken, with optional speech tags such as [laugh] or <whisper>…</whisper>. Billed per 1,000 characters, tags included. |
voice_id可选 | string | eve | ara, eve, leo, rex, sal, jpi39icg, d18jlf6v, 33g9t0jl, 26w6ihxi, dr8gqysu, wy0m9l5w, om17cury, x7avnu1k, bcs7l2c3, … (+57) | Preset voice. Eve, Ara, Leo, Rex and Sal speak every supported language; the others are tuned for one language. |
language可选 | string | auto | auto, en, zh, ar-EG, ar-SA, ar-AE, bn, fr, de, hi, id, it, ja, ko, … (+7) | Reading language, or auto to detect it from the text. |
speed可选 | number | 1 | 0.7 到 1.5 | Speaking speed from 0.7 (slower) to 1.5 (faster). |
output_format可选 | string | mp3 | mp3, wav, pcm, mulaw, alaw | Audio encoding. pcm, mulaw and alaw are raw streams without a file header, for phone systems. |
sample_rate可选 | integer | 24000 | 8000, 16000, 22050, 24000, 44100, 48000 | Sample rate in Hz. 8000 for phone lines, 44100 or 48000 for studio work. |
bitrate可选 | integer | 128000 | 32000, 64000, 96000, 128000, 192000 | MP3 bit rate in bits per second. Only applies to mp3. |
text_normalization可选 | boolean | false | — | Rewrite numbers, abbreviations and symbols as spoken words before reading. |
optimize_streaming_latency可选 | integer | 0 | 0, 1, 2 | Streaming latency level: 0 best quality, 1 smaller first chunk, 2 smallest first chunk with more quality trade-off at chunk boundaries. |
请求示例
这段请求原样就能运行,没写的字段都用默认值。运行前先把密钥放进环境变量 POPNOW_API_KEY。
curl -X POST "https://api.popnow.ai/api/v1/jobs/createTask" \
-H "Authorization: Bearer $POPNOW_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "xai/grok-tts/text-to-speech",
"input": {
"text": "Hi there! This voice was created with the PopNow API in just a few seconds."
}
}'响应里会立刻带回 taskId。之后用 GET /api/v1/jobs/recordInfo 取结果,或者在请求里加上 callBackUrl 等通知。
curl "https://api.popnow.ai/api/v1/jobs/recordInfo?taskId=TASK_ID_FROM_CREATE_TASK" \
-H "Authorization: Bearer $POPNOW_API_KEY"
