Speech(Text to Speech tts-1)
POST
/audio/speechOpenAI Guide
OpenAI API Reference
Transcribe input text into audio.
The Audio API provides a speech endpoint based on our TTS (Text-to-Speech) model. It comes with 6 built-in voices and can be used for:
- Narrating written blog posts
- Creating spoken audio in multiple languages
- Streaming real-time audio output
Price: 7.5 PTC / 1M characters
Price: 15 PTC / 1M characters (High-Quality Voice)
请求参数
Header Params
Content-Type
string
required
Example:
application/json
Authorization
string
required
API Key from 302.AI backend
Example:
Bearer {{YOUR_API_KEY}}
Body Params application/json
model
string
required
One of the available TTS models: tts-1 or tts-1-hd
input
string
required
The text to be converted to speech, maximum length is 4096 characters.
voice
string
required
The voice to use for audio generation. Supported voices are: alloy, echo, fable, onyx, nova and shimmer.
response_format
string
optional
Defaults to mp3 audio format. Supported formats are: mp3, opus, aac and flac.
speed
number
optional
Defaults to 1 for audio generation speed. Choose a value between 0.25 and 4.0, with 1.0 being the default value.
Example
{
"model": "tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}
示例代码
Responses
Success(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
Data Schema
object {0}
Example
{
"model": "tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}
Last modified: 2 个月前