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
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
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
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