AiBrary
ChatAiBrary Website
  • Getting Started
    • 👋Welcome to AiBrary Docs
  • 🧑‍🔬Try APIs
  • 🪙All Pricing
  • Chat & Multimodal Features
    • Chat
      • Chat Pricing
      • Multimodal Pricing
  • Audio Features
    • Speech To Text
      • Pricing
    • Text To Speech
      • Pricing
  • Translation Features
    • Automatic Translation
      • Pricing
  • Image Features
    • Image Generation
      • Pricing
    • Object Detection
      • Pricing
    • Image Embedding
      • Pricing
  • OCR Features
    • OCR
      • Pricing
  • Embedding
    • Embedding
      • Pricing
  • Video Features
    • Coming Soon!
Powered by GitBook
On this page
  1. Audio Features

Text To Speech

PreviousPricingNextPricing

Last updated 2 months ago

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