Text to Speech API Documentation for Developers

By Transit Voice API editorial team · Updated 2026-11-18

This documentation details the Text-to-Speech API endpoint for Transit Voice, designed for developers integrating audio announcements into transport networks. You will find the exact request structure, available parameters, and voice presets required to generate synthetic speech for large-scale announcement systems.

The guide covers authentication using Bearer tokens, rate limits of 60 requests per minute, and supported output formats like MP3 and WAV. It includes concrete code examples in Python and cURL to help you integrate the API quickly into your existing infrastructure.

Text to Speech API Documentation for Developers

Frequently asked questions

What is the API endpoint URL?

The endpoint is POST https://api.vv72thai.com/v1/audio/speech. This URL handles all text-to-speech synthesis requests. You send JSON payloads containing your text, voice selection, and other parameters to this specific path. It is the primary interface for generating audio files from your input text strings.

How do I authenticate my requests?

Include an Authorization header with the value Bearer followed by your API key. Each account has one active key. You can generate a new key at any time; the old one stops immediately. Ensure your key starts with tts- and is sent with every request.

What models are available?

Two models are available: tts-1 and tts-1-hd. Both use the same engine and have identical pricing. Choose based on your quality preference. The model field is required in your request JSON. There are no other model variants or tiers available in the current system.

Can I change the speed of the voice?

Yes, you can adjust the speed using the speed parameter. The acceptable range is from 0.25 to 4.0. This allows you to slow down or speed up the generated audio. The default speed is 1.0. Adjust this value to fit your specific announcement or narration needs.

How do I specify the language?

Use the optional language field with an ISO code. If omitted, the system guesses the language from the script, defaulting to English for Latin text. For non-English Latin text, explicitly set the language parameter to ensure correct synthesis. Supported languages include English, Spanish, German, Arabic, Chinese, Danish, Dutch, Finnish, French, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Swahili, Swedish, and Turkish.

What is the maximum input length?

The maximum input length is 4096 characters per request. This limit applies to the input field in your JSON payload. If your text exceeds this, you must split it into smaller parts. Each part generates a separate audio file that you can join later.

Which audio formats are supported?

You can request audio in mp3, wav, opus, flac, or pcm formats. Specify the desired format using the response_format field in your request. Each format serves different use cases, from web playback to high-quality archival. The choice does not affect the pricing or processing time.

What happens if I hit the rate limit?

The limit is 60 requests per minute per key (10 for new accounts). If you exceed the limit, requests may queue or fail. Failed requests are free. Since there are no plans, you cannot upgrade your rate limit; you must wait for the rate window to reset before sending new requests.

Do I need to split long texts manually?

Yes, you must split texts longer than 4096 characters manually. The API does not handle automatic splitting. Split your text into chunks, send each chunk as a separate request, and then join the resulting audio files in your application logic. This ensures compliance with the input limit.

How do I install the OpenAI SDK?

Install the OpenAI SDK for your language via your package manager, such as pip install openai for Python. Configure it to use our API by setting the base_url to https://api.vv72thai.com/v1 and providing your Bearer token. This allows you to use standard OpenAI SDK methods with our Transit Voice API endpoints.

Is the base URL the same as OpenAI?

No, the base URL is https://api.vv72thai.com/v1. It is not the same as OpenAI’s base URL. You must configure your SDK or HTTP client to point to this specific domain. The request shape is compatible, but the endpoint domain is distinct and specific to Transit Voice API.

How do I handle errors in my code?

Check the HTTP status code and response body for error details. Failed synthesis requests return a full refund of the character cost. Implement retry logic for temporary issues. The API returns standard error codes. Log the response to debug issues with input text or voice parameters.

Can I use this with Node.js?

Yes, you can use this API with Node.js. Use the official OpenAI SDK or plain HTTP requests. Configure the base_url to https://api.vv72thai.com/v1. Send your API key in the Authorization header. The SDK handles JSON serialization and response parsing efficiently for your Node.js applications.

How do I test the API before production?

Sign up to receive $0.50 in free trial credit valid for 7 days. Use this credit to test various voices, languages, and formats. Send small text samples to verify integration. Check the balance and usage in your dashboard. This allows you to validate the workflow without immediate cost.

First request

curl

curl https://api.vv72thai.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.vv72thai.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.vv72thai.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

Authentication is handled via a Bearer token passed in the Authorization header. Include the header Authorization: Bearer tts-<your-key> with every request to the API base URL.

Bearer token in Authorization header

Pass your API key as a Bearer token in the Authorization header of each HTTP request. This token authenticates the request against your account's balance and rate limits.

One active key per account

Each account maintains a single active API key. You do not manage multiple keys simultaneously; the system validates requests against this unique credential.

Key revocation and issuance

Issue a new key at any time via the dashboard. The previous key stops working immediately, ensuring no overlap or confusion in transport team deployments.

Revoking is instant, which is critical for security in large network environments where credentials may be exposed in multiple client configurations.

Speech Synthesis Endpoint

Sound wave illustration for: Speech Synthesis Endpoint

Send text to the synthesis endpoint and receive an audio file. The API accepts JSON payloads and returns binary audio data directly in the response body. This endpoint powers all voice generation for transport announcements and team notifications.

Use the standard request shape compatible with OpenAI SDKs. Configure the model, input text, and voice preset to generate speech. The system processes requests sequentially, so long texts may queue during high load.

POST /v1/audio/speech

Endpoint URL: POST https://api.vv72thai.com/v1/audio/speech

Returns binary audio data matching the requested format.

JSON body structure

The request body is a standard JSON object containing synthesis parameters. The API validates inputs before processing and returns errors for invalid formats.

All string fields are treated as UTF-8. Spaces and punctuation count toward the character limit.

  • model: "tts-1" or "tts-1-hd"
  • input: string up to 4096 characters
  • voice: one of 8 presets
  • response_format: mp3, wav, opus, flac, or pcm
  • speed: 0.25–4.0
  • language: optional ISO code

Required fields: model, input, voice

model selects the engine quality. Both "tts-1" and "tts-1-hd" use the same engine and price.

input is the text to convert. It must be under 4096 characters. Split longer texts manually.

voice determines the speaker. Select from 8 presets based on your announcement style.

Speech Synthesis Endpoint

Request Parameters

Sound wave illustration for: Request Parameters

Configure request parameters to control audio generation behavior. The API accepts standard JSON fields for model selection, voice preset, and input text, ensuring straightforward integration with existing transport management systems.

Text input limit of 4096 characters

Each request supports up to 4096 characters of input text. For announcements exceeding this limit, split the text into chunks and join the resulting audio files sequentially. Spaces and punctuation count toward the character limit.

Speed adjustment from 0.25 to 4.0

Adjust playback speed using the speed parameter, ranging from 0.25 to 4.0. This allows fine-tuning for clarity in noisy environments or faster broadcast cycles without requiring post-processing.

Optional language ISO code

Set the language field with an ISO code to force detection, especially for non-English Latin-script text. If omitted, the system guesses the language, defaulting to English for Latin scripts.

Response Formats

Sound wave illustration for: Response Formats

The API returns the complete audio file as the response body. This endpoint provides the full synthesis result in a single transaction, ensuring reliable delivery for transport announcement systems.

MP3, WAV, OPUS, FLAC, PCM

Select the format that matches your playback infrastructure. MP3 and OPUS offer efficient compression for standard distribution, while WAV and FLAC provide lossless quality for archival or high-fidelity playback systems. PCM is available for raw data processing.

Binary audio data in response

The response body contains the raw bytes of the generated audio file. There is no JSON wrapper around the audio content; it is delivered as direct binary data, ready to be saved or played by your client application.

Content-Type header details

The server sets the Content-Type header to match the selected response_format (e.g., audio/mpeg, audio/wav, audio/opus, audio/flac, or audio/pcm). This allows your application to correctly identify and handle the audio file without manual extension guessing.

Voice Selection

Sound wave illustration for: Voice Selection

Select the appropriate voice preset based on your announcement context. Each preset is optimized for specific tonal qualities, ensuring consistent audio output across your transport network. The API supports eight distinct voice models, allowing you to match the voice to the content type, whether it’s emergency alerts or routine schedule updates.

All voices support all 23 languages. You can specify the language via the ISO code in the request or let the system guess it from the script. For non-English Latin text, explicitly setting the language parameter is recommended to avoid defaulting to English.

8 available voice presets

The API provides eight voice presets divided into four female and four male voices. Each voice is derived from licensed recordings, ensuring high-quality synthetic speech without the need for custom training.

You can switch voices per request, allowing you to use different voices for different announcements within the same project. This flexibility supports varied audio branding across different transport hubs or routes.

  • aria: warm, clear narrator
  • nova: bright, upbeat
  • luna: soft, storytelling
  • sage: calm, instructional
  • felix: energetic, promo
  • milo: friendly, conversational
  • atlas: neutral, news
  • orion: deep, documentary

Female and male options

The four female voices (aria, nova, luna, sage) offer a range of tones from warm to soft. The four male voices (felix, milo, atlas, orion) provide options from energetic to deep. This variety allows you to select a voice that best fits the urgency or tone of your announcements.

All voices can speak any of the 23 supported languages. This means you do not need to select different voices for different languages. A single voice can handle multilingual announcements, simplifying your API integration.

Voice characteristics summary

Each voice has distinct characteristics. For example, atlas is neutral and suitable for news-style updates, while felix is energetic and ideal for promotional announcements. Orion’s deep tone is well-suited for documentary-style content or long-form instructions.

The voices are based on licensed recordings from LibriTTS-R (CC BY 4.0). Every generated audio file includes an inaudible watermark, marking it as synthetic speech. This ensures transparency in your audio outputs.

Voice Selection

Rate Limits

Sound wave illustration for: Rate Limits

The API enforces a standard rate limit of 60 requests per minute per API key. This capacity is sufficient for most transport announcement workflows, where batches of text are converted to speech for public address systems or mobile devices.

60 requests per minute per key

Each API key operates under a maximum throughput of 60 requests per minute. This limit applies uniformly across all authenticated requests to the speech endpoint, ensuring predictable performance for large transport teams generating announcement audio.

10 requests per minute initially

New accounts begin with a restricted limit of 10 requests per minute. This lower threshold applies before the first top-up, allowing initial testing while preventing excessive load on the infrastructure without a verified payment method.

Limit increase after top-up

The rate limit remains at 10 requests per minute until the first top-up is completed. Once a top-up is completed via USDT (TRC-20), the standard limit of 60 requests per minute is enforced immediately, supporting higher-volume announcement generation.

Error Handling

Sound wave illustration for: Error Handling

The API returns standard HTTP status codes to indicate request success or failure. Use these codes to determine whether to retry or terminate the call in your transport automation pipeline.

Standard HTTP error codes

Use 400 for invalid parameters, 401 for authentication failures, and 429 for rate limit exceeded. A 500 error indicates a server-side synthesis issue. Always check the response body for a specific error message and code.

Common failure scenarios

Failures typically occur due to malformed JSON, unsupported voice IDs, or exceeding the 4096 character limit per request. Network timeouts may also occur during high load when requests wait in the queue.

  • Invalid voice parameter
  • Text exceeds 4096 characters
  • Malformed JSON body

Refund on synthesis failure

If synthesis fails, the charge is returned in full. Failed requests incur no cost, ensuring you only pay for successfully generated audio files. This applies to both standard and HD models.

Error Handling

Code Examples

Sound wave illustration for: Code Examples

The API accepts standard JSON payloads, making integration straightforward across different infrastructure stacks. You can trigger synthesis directly from command-line tools or embed calls within application logic without requiring a proprietary client library.

Below are three standard implementations covering common development environments. Each example demonstrates the required authentication header, voice selection, and text input structure defined in the specification.

cURL command line example

Use this command to generate speech directly from your terminal. Replace YOUR_API_KEY with your active token and adjust the voice parameter as needed.

```bash curl -X POST https://api.vv72thai.com/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "tts-1", "input": "Attention passengers, the next stop is Central Station.", "voice": "atlas", "response_format": "mp3"}' \ -o announcement.mp3 ```

Python OpenAI SDK usage

The official OpenAI SDK works by pointing to our base URL. Initialize the client with your key and endpoint, then call the audio endpoint to receive binary data.

```python import openai client = openai.OpenAI( api_key="YOUR_API_KEY", base_url="https://api.vv72thai.com/v1" ) with client.audio.speech.with_streaming_response.create( model="tts-1", voice="nova", input="System check complete. All routes operational.", response_format="wav" ) as response: response.stream_to_file("check.wav") ```

JavaScript fetch example

For web-based transport management interfaces, use the native fetch API. Ensure you handle the binary response correctly to save the audio file or play it directly.

```javascript const response = await fetch('https://api.vv72thai.com/v1/audio/speech', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'tts-1', voice: 'sage', input: 'Service delay expected. Please wait.', response_format: 'mp3' }) }); const blob = await response.blob(); // Save or play blob ```

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Team, please gather near the central entrance for your mandatory briefing and safety instructions before the shift begins.

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. TRON developer hub: TRC-20
  3. LibriTTS-R corpus (OpenSLR 141)
  4. openai-node on GitHub
  5. FFmpeg documentation
  6. IETF RFC 7845: Ogg Opus
  7. MDN: Web Speech API
  8. curl documentation
  9. Creative Commons Attribution 4.0
  10. LibriTTS-R paper (arXiv 2305.18802)
  11. OpenAI API reference: create speech
  12. openai-python on GitHub

More on this site