Text To Speech
from aibrary import AiBrary
aibrary = AiBrary()
response = aibrary.audio.speech.create(
input="Hey Cena", model="tts-1", response_format="mp3", voice="alloy"
)
open("file.mp3", "wb").write(response.content)
Authorizations
Body
modelany ofRequired
ID of the TTS model to use. Options depend on the provider (e.g., 'tts-1' for one provider, 'microsoft' for another).
stringOptional
string[]Optional
inputstringRequired
The text to be synthesized into speech. Maximum length may vary by provider.
voicestringRequired
The desired voice for the synthesized speech. Options depend on the provider.
languageany ofOptionalDefault:
Language code (e.g., 'en', 'fr'). Defaults to English.
en
stringOptional
nullOptional
response_formatany ofOptionalDefault:
Desired audio format (e.g., 'mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'). Defaults to MP3.
mp3
stringOptional
nullOptional
speedany ofOptionalDefault:
Speech rate adjustment. Select a value from 0.25 to 4.0. Defaults to 1.0 (normal speed).
1
numberOptional
nullOptional
Responses
200
Successful Response
application/json
Responseany
422
Validation Error
application/json
post
POST /v0/audio/speech HTTP/1.1
Host: api.aibrary.dev
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 92
{
"model": "tts-1",
"input": "Hello how are you today?",
"voice": "alloy",
"response_format": "mp3"
}
No content
Last updated