curl -X POST "https://t.ato2.nodesms.com/v1/audio/translations" \
-H "Authorization: Bearer $API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
audio_file = open("audio.mp3", "rb")
translation = client.audio.translations.create(
model="whisper-1",
file=audio_file
)
print(translation.text)
{
"text": "Hello, this is a test in English."
}
{
"error": {
"message": "string",
"type": "invalid_request_error",
"param": "file",
"code": "string"
}
}
{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}
音频翻译
将音频文件翻译为英文文本,支持多种语言源音频。
POST
/
v1
/
audio
/
translations
curl -X POST "https://t.ato2.nodesms.com/v1/audio/translations" \
-H "Authorization: Bearer $API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
audio_file = open("audio.mp3", "rb")
translation = client.audio.translations.create(
model="whisper-1",
file=audio_file
)
print(translation.text)
{
"text": "Hello, this is a test in English."
}
{
"error": {
"message": "string",
"type": "invalid_request_error",
"param": "file",
"code": "string"
}
}
{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}
请求头
string
必填
Bearer Token 认证,格式:
Bearer sk-xxxxxxstring
必填
固定值为
multipart/form-data请求体
file
必填
要翻译的音频文件。格式为二进制,支持多种音频格式(如 mp3、mp4、mpeg、mpga、m4a、wav、webm)。
string
必填
模型 ID。例如
whisper-1。string
用于指导模型风格或继续先前音频片段的可选文本提示。提示应为英文。
string
默认值:"json"
翻译输出格式。可选值为
json、text、srt、verbose_json、vtt。默认值为 json。number
采样温度,介于 0 和 1 之间。默认值为 0。
响应
string
翻译生成的英文文本。
curl -X POST "https://t.ato2.nodesms.com/v1/audio/translations" \
-H "Authorization: Bearer $API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
audio_file = open("audio.mp3", "rb")
translation = client.audio.translations.create(
model="whisper-1",
file=audio_file
)
print(translation.text)
{
"text": "Hello, this is a test in English."
}
{
"error": {
"message": "string",
"type": "invalid_request_error",
"param": "file",
"code": "string"
}
}
{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}
最后修改于 2026年10月28日
此页面对您有帮助吗?