ohmygpt-logoOhMyGPT Cookbook
OpenAPI/V1/Audio

TTS文本转语音服务

OpenAI 最新款的文本转语音(TTS)模型

效果非常棒,媲美真实人声,一个声音就原生支持多国语言,站长觉得它的效果比Azure的神经网络语音引擎还要牛x,对于语言学习类、AI对话交流类、AI朗读(听书、网页阅读)等方面的应用应该很有帮助。

POST
/v1/audio/speech

Authorization

AuthorizationRequiredBearer <token>

In: header

Request Body

application/x-www-form-urlencodedOptional
modelRequiredstring

可用的 TTS 模型之一:tts-1 或 tts-1-hd

inputRequiredstring

要为其生成音频的文本。 最大长度为 4096 个字符。(string.length)

voiceRequiredstring

生成音频时使用的语音。 支持的声音有: alloy, echo, fable, onyx, nova, shimmer

response_formatstring

返回音频格式,支持mp3, opus, aac, and flac.

speedstring

语速,范围:[0.25, 4.0]

Response Body

TypeScript Definitions

Use the response body type in TypeScript.

curl -X POST "https://api.ohmygpt.com/v1/audio/speech" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d 'model=tts-1&input=The+quick+brown+fox+jumped+over+the+lazy+dog.&voice=alloy&response_format=mp3&speed=1'
{}