curl --fail-with-body "https://api.mosshub.cn/v1/audio/speech" \
--header "Authorization: Bearer $MOSSHUB_API_KEY" \
--header "Content-Type: application/json" \
--output speech.wav \
--data '{
"model": "<模型标识>",
"input": "你好,欢迎使用 MossHub。",
"voice": "<音色标识>",
"response_format": "wav"
}'
音频模型
语音合成
将文本转换为音频,直接接收音频响应字节。
curl --fail-with-body "https://api.mosshub.cn/v1/audio/speech" \
--header "Authorization: Bearer $MOSSHUB_API_KEY" \
--header "Content-Type: application/json" \
--output speech.wav \
--data '{
"model": "<模型标识>",
"input": "你好,欢迎使用 MossHub。",
"voice": "<音色标识>",
"response_format": "wav"
}'
模型必须支持
audio_speech 协议。音色、音频格式与文本长度限制以模型说明为准。
请求参数
string
必填
获准使用的语音模型标识。将示例中的
<模型标识> 替换为控制台显示的精确值。string
必填
要合成的文本。
string
必填
当前模型支持的音色标识。将示例中的
<音色标识> 替换为模型支持的值。string
当前模型支持的音频格式,示例使用
wav。返回内容
成功响应为音频字节,Content-Type 为audio/* 或 application/octet-stream。直接写入文件或交给音频播放器,不能按 JSON 解析。
此接口不接受 stream: true 或 SSE 输出。需要传入 stream_format 时,仅支持 audio。
curl --fail-with-body "https://api.mosshub.cn/v1/audio/speech" \
--header "Authorization: Bearer $MOSSHUB_API_KEY" \
--header "Content-Type: application/json" \
--output speech.wav \
--data '{
"model": "<模型标识>",
"input": "你好,欢迎使用 MossHub。",
"voice": "<音色标识>",
"response_format": "wav"
}'