API Documentation for Text-to-Speech Integration

By TransitVoice editorial team · Updated 2026-11-18

This documentation guides transportation startups and classifieds platforms through integrating our text-to-speech API. You will learn how to turn route updates, driver alerts, and ad descriptions into natural audio files using standard HTTP requests. The guide covers authentication, the OpenAI SDK setup, and parameter details for seamless integration.

Designed for developers, this page explains how to generate clear, multi-language audio without hiring voice actors. We provide concrete examples for cURL and the OpenAI SDK, along with details on voices, formats, and rate limits. Follow these steps to keep your users engaged with reliable, synthesized speech in minutes.

API Documentation for Text-to-Speech Integration

Frequently asked questions

How do I get my API key?

Sign up on the /get-api-key/ page using Google or an email and password. Your account is specific to this site. The dashboard displays your active API key, which you use for authentication. You can issue a new key at any time, which immediately invalidates the previous one.

Is the API compatible with OpenAI SDK?

Yes. The request shape matches the OpenAI speech endpoint exactly. You can use official OpenAI SDKs by changing the base_url to https://api.playbw52.com/v1 and providing your site-specific API key. This allows for quick integration without rewriting your existing client logic.

What is the base URL for the API?

The base URL is https://api.playbw52.com/v1. You send POST requests to https://api.playbw52.com/v1/audio/speech. Other endpoints like /v1/voices and /v1/models are also available at this base path for retrieving voice lists and model information.

How do I set the voice parameter?

Choose one of eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. These voices are based on licensed recordings: LibriTTS-R (CC BY 4.0), from LibriVox public-domain audiobook readings. You can view the full list and details by sending a GET request to /v1/voices.

Can I change the speed of the audio?

Yes, you can adjust the speed between 0.25 and 4.0. This allows you to speed up or slow down the narration to fit your content needs. The default speed is 1.0. This parameter is part of the JSON body sent to the speech endpoint.

What languages are supported in the API?

We support 23 languages: Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, and Turkish. Any voice can speak any supported language. If you omit the language parameter, the system guesses it from the script, defaulting to English for Latin text.

How do I handle long texts?

Split your text into parts of up to 4096 characters. Send each part as a separate request to the API. Then, join the resulting audio files together on your end. This ensures compliance with the character limit per request.

What happens if I exceed the rate limit?

The limit is 60 requests per minute per key (10 per minute before the first top-up). If you exceed this, requests may queue or fail. Failed requests are free, so you will not be charged for audio that does not generate successfully.

Is SSL required for API requests?

Yes, all API requests should be made over HTTPS to the specified base URL. This ensures secure transmission of your API key and text data. The endpoint https://api.playbw52.com/v1/audio/speech is designed for secure, encrypted communication.

Can I use the API with Python?

Yes, you can use the official OpenAI Python SDK. Simply configure the base_url to https://api.playbw52.com/v1 and provide your API key. Alternatively, you can use any standard HTTP library like requests to send POST requests with the required JSON body.

How do I receive the audio file?

The API returns the audio file directly in the response body. Supported formats include mp3, wav, opus, flac, and pcm. You can save this binary data to a file on your server or serve it directly to your users.

Are there any headers required?

You must include the Authorization header with your API key. The format is: Authorization: Bearer tts-... Your key is found on the /get-api-key/ dashboard. No other headers are strictly required, but standard content-type headers may be needed depending on your client.

What is the maximum text length?

The maximum input text length is 4096 characters per request. This limit applies to each individual API call. For longer texts, you must split the content into chunks of 4096 characters or less and process them sequentially.

How do I test the API before production?

Sign in with Google to receive a $0.50 free trial (approx. 50,000 characters). Use the dashboard’s ready curl example to test voices, languages, and formats. Note: Email-signup accounts start without trial credit. Once satisfied, top up with USDT on the TRON network (TRC-20) to continue generating audio for your transportation or classifieds platform.

First request

curl

curl https://api.playbw52.com/v1/audio/speech \
  -H "Authorization: Bearer $TTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"tts-1","voice":"aria","input":"Hello from the API.","response_format":"mp3"}' \
  --output hello.mp3

Python (openai)

from openai import OpenAI

client = OpenAI(base_url="https://api.playbw52.com/v1", api_key="tts-...")

with client.audio.speech.with_streaming_response.create(
    model="tts-1", voice="nova", input="Hello from Python.", response_format="mp3"
) as response:
    response.stream_to_file("hello.mp3")

Node.js (openai)

import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({ baseURL: "https://api.playbw52.com/v1", apiKey: process.env.TTS_API_KEY });
const res = await client.audio.speech.create({ model: "tts-1", voice: "milo", input: "Hello from Node.js." });
fs.writeFileSync("hello.mp3", Buffer.from(await res.arrayBuffer()));
voice
ariafemale
novafemale
lunafemale
sagefemale
felixmale
milomale
atlasmale
orionmale
language
arالعربية
zh中文
daDansk
nlNederlands
enEnglish
fiSuomi
frFrançais
deDeutsch
elΕλληνικά
heעברית
hiहिन्दी
itItaliano
ja日本語
ko한국어
msBahasa Melayu
noNorsk
plPolski
ptPortuguês
ruРусский
esEspañol
swKiswahili
svSvenska
trTürkçe

Authentication

Sound wave illustration for: Authentication

TransitVoice secures your API requests with a single bearer token, ensuring your route updates and driver alerts are processed reliably. This key authenticates all calls to the API base URL, allowing your transportation startup to integrate text-to-speech without complex setup.

Bearer Token Setup

Include your token in the Authorization header as Bearer tts-... for every request. You can generate this key on the /get-api-key/ page after signing up with Google or your email.

API Key Management

Each account holds one active key. You can view your current key, balance, and usage statistics directly on your dashboard. The key remains valid until you rotate it or create a new one.

Key Rotation

Issue a new key at any time via the dashboard. The previous key stops working immediately, ensuring no overlap or accidental usage after rotation. This is useful if you suspect exposure or need to reset access for your classifieds platform.

Quickstart with cURL

Sound wave illustration for: Quickstart with cURL

We help transportation startups turn route updates into audio quickly. Use cURL to send text and receive speech files directly. This approach requires no custom SDKs, just standard HTTP tools your team already knows.

First Request Example

Send a POST request to the speech endpoint. Replace YOUR_API_KEY with your key from /get-api-key/. The text must be under 4,096 characters. For longer texts, split them into chunks and join the resulting audio files.

Example: `curl -X POST https://api.playbw52.com/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "Next stop: Central Station.", "voice": "aria", "response_format": "mp3"}'`

JSON Body Structure

The request body is JSON. Required fields are model, input, and voice. You can optionally set response_format, speed, and language. The language field helps if the script is ambiguous, like Latin text that isn't English.

Supported formats include mp3, wav, opus, flac, and pcm. Speed ranges from 0.25 to 4.0. The model field accepts either "tts-1" or "tts-1-hd", which use the same engine and pricing.

  • model: "tts-1" or "tts-1-hd"
  • input: string, max 4096 characters
  • voice: one of 8 presets (e.g., aria, nova)
  • response_format: mp3, wav, opus, flac, pcm

Response Format

A successful request returns the audio file directly in the response body. The content type matches your chosen format. Failed requests are free, but the response structure for errors is not strictly defined as JSON objects. Handle binary data appropriately in your client.

Quickstart with cURL

OpenAI SDK Integration

Sound wave illustration for: OpenAI SDK Integration

TransitVoice’s speech endpoint mirrors the OpenAI API shape, allowing you to integrate text-to-speech into your transportation or classifieds app using existing code. You simply update the base URL in your client configuration to point to our API, enabling seamless adoption without rewriting your audio generation logic.

Change Base URL

Point your OpenAI SDK client to https://api.playbw52.com/v1. This directs all speech requests to our infrastructure while maintaining standard request structures and response formats.

Use Official SDKs

The official OpenAI SDKs work directly with our endpoint. This means you can leverage familiar libraries in your preferred language to handle authentication, retries, and response parsing without building a custom client from scratch.

Compatibility Notes

While the request shape matches, ensure your SDK version supports the tts-1 model identifiers. Standard parameters like voice, model, and input behave identically to the OpenAI standard, but rate limits and character counts are specific to TransitVoice.

  • Base URL: https://api.playbw52.com/v1
  • Models: tts-1, tts-1-hd
  • Auth: Bearer token via standard headers

Endpoints

Sound wave illustration for: Endpoints

The TransitVoice API exposes three core endpoints to manage your speech synthesis workflow. The primary endpoint handles audio generation, while the companion endpoints provide reference data for available voices and models, allowing your application to dynamically adapt to the latest engine updates.

POST /v1/audio/speech

Send text to generate audio files. Accepts JSON bodies with fields like model, input, voice, response_format, and speed. The engine returns the audio file directly in the response, ready for playback or storage in your transportation or classifieds platform.

GET /v1/voices

Retrieve a list of all available voice presets, their associated languages, and supported audio formats. Since the API does not support server-side filtering, you can fetch this list and filter locally to find the perfect match for your transportation startup's brand voice.

GET /v1/models

Fetch current model metadata to understand available engine options. This endpoint helps you verify which models are active and their associated pricing tiers, ensuring your integration aligns with the latest technical specifications.

Parameters

Sound wave illustration for: Parameters

Configure your synthesis requests using the model, voice, and speed parameters. These controls determine the engine behavior, vocal timbre, and playback tempo, allowing you to tailor the audio output for specific transportation or classifieds use cases without additional cost or complexity.

Model Selection

Select either tts-1 or tts-1-hd. Both models use the same underlying engine and incur identical pricing at $10 per million characters, giving you flexibility in model choice without affecting your billing or production quality.

Voice Presets

Choose from eight distinct voice presets, ranging from the warm narrator style of Aria to the deep documentary tone of Orion. Any voice supports all 23 available languages, so you can select the perfect tone for driver alerts or route updates regardless of the spoken language.

  • Female: aria, nova, luna, sage
  • Male: felix, milo, atlas, orion

Speed Control

Adjust the speed parameter between 0.25 and 4.0 to match your content pacing. Slower speeds improve clarity for complex route instructions, while faster tempos suit quick ad descriptions. The system processes requests sequentially, so extreme speeds may slightly affect generation latency under load.

Parameters

Audio Formats

Sound wave illustration for: Audio Formats

TransitVoice supports MP3, WAV, Opus, FLAC, and PCM formats, allowing you to balance audio fidelity with bandwidth efficiency. You can select the appropriate encoding directly in your request to match your application's needs, whether for mobile apps or desktop tools.

MP3 Support

MP3 is an efficient choice for mobile applications where conserving bandwidth is critical. It provides a good balance between file size and audio quality, making it suitable for route updates and driver alerts delivered over cellular networks.

WAV Quality

WAV offers uncompressed, lossless audio for the highest fidelity. This format is ideal for desktop tools or internal systems where storage space is less of a concern and audio clarity is paramount for driver notifications.

FLAC and PCM

FLAC provides lossless compression, reducing file size without sacrificing audio quality. PCM offers raw, uncompressed audio data, which is useful for direct processing or playback systems that require specific bit-depth or sample rate handling.

Rate Limits

Sound wave illustration for: Rate Limits

Every API key starts with a limit of 10 requests per minute. Once you top up your balance with USDT on the TRON network (TRC-20), this increases to 60 requests per minute. This limit applies globally to your active key, so monitor your usage closely to avoid throttling during peak transit updates.

60 Requests Per Minute

The standard limit for new keys is 10 requests per minute. After a successful top-up of at least $5, your limit rises to 60 requests per minute. This ensures your driver alerts and route notifications remain timely without overwhelming the synthesis engine.

Queue Behavior

Requests are processed sequentially. Under heavy load, a request may wait in a queue before synthesis begins. Long texts split into multiple parts will also wait for previous chunks to finish. Expect slight delays during high-traffic periods, but no requests are lost.

Top-Up Benefits

Top-ups are done via USDT (TRC-20) and credit automatically within minutes. The higher rate limit is tied to your active balance. Since there are no monthly plans, your limit scales with your usage, ensuring you only pay for the throughput you actually need.

  • Minimum top-up: $5
  • Credit time: within minutes
  • Method: USDT on TRON (TRC-20)
Rate Limits

Error Handling

Sound wave illustration for: Error Handling

Errors usually stem from invalid inputs, such as exceeding the 4096-character limit, or using an unsupported voice. Your application should parse the JSON response to identify the specific issue and adjust the request parameters accordingly.

Common Error Codes

While specific HTTP status codes are not officially defined in our documentation, standard conventions apply. A 4xx error typically indicates invalid input, while a 5xx error suggests a server-side issue. Check the response body for detailed messages.

Retry Strategy

Implement exponential backoff for transient errors. Since requests are processed sequentially, a request may wait in a queue under load. Retry with increasing delays to avoid overwhelming the API during peak times.

  • Start with a 1-second delay
  • Double the delay for each retry
  • Max retries: 3-5 attempts

Failed Request Billing

If synthesis fails, the charge is returned in full. You are only billed for successful audio generation. Failed requests do not consume your character allowance.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Streamline your logistics and reach buyers instantly through our unified platform.

Avatar of the voice aria
ariafemale
Avatar of the voice nova
novafemale
Avatar of the voice luna
lunafemale
Avatar of the voice sage
sagefemale
Avatar of the voice felix
felixmale
Avatar of the voice milo
milomale
Avatar of the voice atlas
atlasmale
Avatar of the voice orion
orionmale

23 languages

Any voice speaks any of these languages.

Sources and further reading

  1. Wikipedia
  2. Tether (USDT)
  3. TRON developer hub: TRC-20
  4. openai-python on GitHub
  5. LibriVox public-domain audiobooks
  6. openai-node on GitHub
  7. W3C WAI: making audio and video accessible
  8. IETF RFC 7845: Ogg Opus
  9. Python documentation
  10. ISO 639 language codes
  11. FFmpeg documentation
  12. curl documentation

More on this site