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)

Generation

post
/v0/audio/speech
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
or
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 ofOptional

Language code (e.g., 'en', 'fr'). Defaults to English.

Default: en
stringOptional
or
nullOptional
response_formatany ofOptional

Desired audio format (e.g., 'mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'). Defaults to MP3.

Default: mp3
stringOptional
or
nullOptional
speedany ofOptional

Speech rate adjustment. Select a value from 0.25 to 4.0. Defaults to 1.0 (normal speed).

Default: 1
numberOptional
or
nullOptional
Responses
200

Successful Response

application/json
Responseany
post
/v0/audio/speech

No content

Last updated