curl -X POST "https://t.ato2.nodesms.com/v1/audio/speech" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}' \
--output speech.mp3
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dog."
)
response.stream_to_file("speech.mp3")
(音频二进制数据,Content-Type: audio/mpeg)
音频合成
将文本转换为音频
POST
/
v1
/
audio
/
speech
curl -X POST "https://t.ato2.nodesms.com/v1/audio/speech" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}' \
--output speech.mp3
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dog."
)
response.stream_to_file("speech.mp3")
(音频二进制数据,Content-Type: audio/mpeg)
请求头
string
必填
使用 Bearer Token 认证。格式:
Authorization: Bearer sk-xxxxxx请求体
格式:application/json
string
必填
模型 ID
string
必填
要转换的文本,长度不超过 4096
string
必填
语音音色,可选值:
alloy、echo、fable、onyx、nova、shimmerstring
默认值:"mp3"
音频输出格式,可选值:
mp3、opus、aac、flac、wav、pcmnumber
默认值:"1"
语速,取值范围
0.25 到 4响应
200 成功生成音频
格式:audio/mpeg
file
音频文件格式:
binarycurl -X POST "https://t.ato2.nodesms.com/v1/audio/speech" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}' \
--output speech.mp3
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxx",
base_url="https://t.ato2.nodesms.com/v1"
)
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dog."
)
response.stream_to_file("speech.mp3")
(音频二进制数据,Content-Type: audio/mpeg)
最后修改于 2026年10月28日
此页面对您有帮助吗?