Saltar para o conteúdo principal
POST
/
v1
/
audio
/
speech
Python (OpenAI SDK)
from openai import OpenAI

client = OpenAI(
    api_key="<COMETAPI_KEY>",
    base_url="https://api.cometapi.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("output.mp3")
"<string>"

Autorizações

Authorization
string
header
obrigatório

Bearer token authentication. Use your CometAPI key.

Corpo

application/json
model
string
padrão:tts-1
obrigatório

The TTS model to use. Choose a current speech model from the Models page.

input
string
obrigatório

The text to generate audio for. Maximum length is 4096 characters.

Maximum string length: 4096
voice
enum<string>
padrão:alloy
obrigatório

The voice to use for speech synthesis.

Opções disponíveis:
alloy,
ash,
ballad,
coral,
echo,
fable,
onyx,
nova,
sage,
shimmer
response_format
enum<string>
padrão:mp3

The audio output format.

Opções disponíveis:
mp3,
opus,
aac,
flac,
wav,
pcm
speed
number
padrão:1

The speed of the generated audio. Select a value between 0.25 and 4.0.

Intervalo necessário: 0.25 <= x <= 4

Resposta

200 - audio/mpeg

The audio file content.

The response is of type file.