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
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
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.
enstringOptional
nullOptional
response_formatany ofOptionalDefault:
Desired audio format (e.g., 'mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'). Defaults to MP3.
mp3stringOptional
nullOptional
speedany ofOptionalDefault:
Speech rate adjustment. Select a value from 0.25 to 4.0. Defaults to 1.0 (normal speed).
1numberOptional
nullOptional
Responses
200
Successful Response
application/json
Responseany
422
Validation Error
application/json
post
/v0/audio/speechNo content
Last updated