音频
使用语音生成、音频转写和音频翻译接口。
音频接口包含语音生成、音频转写和音频翻译。语音生成使用 JSON 请求体;转写和翻译通常使用 multipart 表单上传音频文件。
端点
| 方法 | 路径 | 说明 |
|---|---|---|
POST | /v1/audio/speech | 文本转语音 |
POST | /v1/audio/transcriptions | 音频转写 |
POST | /v1/audio/translations | 音频翻译 |
请求参数
| 字段 | 类型 | 适用接口 | 说明 |
|---|---|---|---|
model | string | 全部 | 音频模型 ID,必填 |
input | string | speech | 要转换为语音的文本 |
voice | string | speech | 声音 ID |
instructions | string | speech | 语音风格或额外指令 |
response_format | string | 全部 | 返回格式。转写/翻译默认 json |
speed | number | speech | 语速 |
stream_format | string | speech | 设置为 sse 时按模型支持启用流式 |
metadata | object | speech | 透传元数据 |
file | file | transcriptions/translations | multipart 表单中的音频文件,必填 |
language | any | 扩展 | 部分渠道支持的语言参数 |
语音生成
curl https://api.tensoraxis.com/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "你好,欢迎使用 TENSORAXIS。",
"response_format": "mp3"
}' \
--output speech.mp3音频转写
curl https://api.tensoraxis.com/v1/audio/transcriptions \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-F model="whisper-1" \
-F file="@audio.mp3" \
-F response_format="json"音频翻译
curl https://api.tensoraxis.com/v1/audio/translations \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-F model="whisper-1" \
-F file="@audio.mp3" \
-F response_format="json"响应结构
转写和翻译的 JSON 响应通常包含 text:
{
"text": "Transcribed text..."
}语音生成会直接返回音频二进制内容,响应 Content-Type 取决于 response_format 和上游模型。