Text-to-Speech API Documentation and Integration Guide

By VocalPath editorial team · Updated 2026-11-18

This documentation guides indie developers in building reliable audio announcement systems for buses, trains, and public spaces using the VocalPath API. You will learn how to send text and receive synthetic speech files with watermark verification in 23 languages. The guide covers integration steps, parameter details, and error handling to help you deploy audio infrastructure without complex setup.

Use this reference to understand authentication, rate limits, and supported formats like MP3, WAV, and OPUS. We provide concrete code examples in Python and Node.js, along with explanations of voice presets and language configuration. Whether you are generating short alerts or long transit updates, this page gives you the specific technical details needed to integrate our text-to-speech API into your project.

Text-to-Speech API Documentation and Integration Guide

Frequently asked questions

How do I get an API key?

Sign up on /get-api-key/ using Google or email. You receive one active key per account. A new key issued immediately invalidates the old one. Google sign-ups include a $0.50 trial credit valid for 7 days. Email accounts start without trial credit.

What is the base URL for the API?

The API base URL is https://api.play2739.com/v1. Use this for all requests. The speech endpoint is POST https://api.play2739.com/v1/audio/speech. Voices and models are available via GET /v1/voices and GET /v1/models respectively.

Can I use the OpenAI SDK?

Yes. The request shape matches the OpenAI speech endpoint. Change the SDK's base_url to https://api.play2739.com/v1 and use your VocalPath key. This allows you to use official OpenAI SDKs directly without custom integration code.

What are the supported models?

Two models are available: "tts-1" and "tts-1-hd". Both use the same engine and price. Choose based on your quality preference. Both support all eight voice presets and all available audio formats for your announcements.

How do I specify a voice?

Include the voice name in the request body. Options include aria, nova, luna, sage, felix, milo, atlas, and orion. Each voice has a distinct tone suitable for different announcement types, from calm instructions to energetic promos.

What is the maximum text length?

Each request supports up to 4096 characters. Spaces and punctuation count toward this limit. For longer texts, split the input into chunks of this size. Generate audio for each chunk and join the files programmatically.

How do I handle rate limits?

The limit is 60 requests per minute per key. Before the first top-up, the limit is 10 requests per minute. Queue requests if needed. Process them sequentially to stay within limits and avoid throttling during high traffic.

What happens on a failed request?

Failed requests are free. If synthesis fails, the charge is returned in full. You can retry the request without incurring additional costs. Check the response status to determine if the generation was successful or if an error occurred.

Can I change my API key?

Yes, you can issue a new key at any time. When a new key is generated, the old one stops working immediately. This allows you to revoke access instantly if needed. Manage keys directly from your account dashboard.

How do I set the language?

Set the optional "language" field to an ISO code. If omitted, the system guesses the language, defaulting to English for Latin script. For non-English Latin text, explicitly set the language to ensure correct pronunciation and accent.

What audio formats are available?

You can choose from mp3, wav, opus, flac, and pcm. Select the format that best fits your playback system. MP3 is efficient for storage, while WAV offers uncompressed quality. All formats include an inaudible synthetic watermark.

Is there a WebSocket endpoint?

No. The API uses standard HTTP request-response. You send a POST request to receive the audio file. There is no WebSocket endpoint, streaming, or real-time partial audio delivery. For live playback, you must fetch the full file first. This design ensures reliable delivery of complete audio assets without complex connection management.

How do I split long texts?

Split text into parts of up to 4096 characters. Send each part as a separate request to the speech endpoint. Receive the audio files for each chunk. Join the audio files programmatically to create a continuous announcement track.

What is the speed range?

The speed range is 0.25 to 4.0. Adjust this parameter to control the playback rate of the generated speech. Lower values slow down the voice, while higher values speed it up. This helps fit announcements into specific time slots.

First request

curl

curl https://api.play2739.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.play2739.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.play2739.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 and API Keys

Sound wave illustration for: Authentication and API Keys

Access the VocalPath API by obtaining a unique key from your dashboard at /get-api-key/. Each account holds one active key that authenticates your requests. This key is the sole credential required to interact with the synthesis endpoint.

Generate your API key on dashboard

Generate your API key on dashboard

Navigate to the /get-api-key/ page to create or retrieve your key. Accounts signed in with Google receive a free trial balance, while email-based accounts start without credit. The dashboard displays your current key, balance, and usage statistics for immediate reference.

  • Keys are unique per account and visible only on the dashboard
  • Trial credit ($0.50) is applied automatically for Google sign-ins
  • Balance and character usage are updated in real-time

Use Bearer token in Authorization header

Use Bearer token in Authorization header

Include your key in the HTTP header using the format Authorization: Bearer tts-.... This standard authentication method works with the official OpenAI SDKs by setting the base URL to https://api.play2739.com/v1. Ensure the token is sent with every synthesis request to validate your account.

  • Header format: Authorization: Bearer <your_key>
  • Compatible with OpenAI SDKs via base_url configuration
  • Required for all POST and GET requests

Revoke and replace keys instantly

You can generate a new key at any time from the dashboard. The previous key becomes invalid immediately upon issuance of the new one, ensuring secure access management without downtime. This feature allows quick response to potential security concerns without affecting your active balance or usage limits.

  • New keys deactivate old keys instantly
  • No service interruption during key rotation
  • Manage access securely without waiting for support

Endpoints Overview

Sound wave illustration for: Endpoints Overview

VocalPath provides three core REST endpoints to manage your text-to-speech workflow. The primary synthesis endpoint accepts your text payload and returns audio files, while metadata endpoints help you discover available voices and model specifications without making any audio generation requests.

POST /v1/audio/speech for synthesis

Send a JSON body containing your text, selected voice, and desired audio format to this endpoint. The API processes the request and returns the generated audio file directly in the response, ready for immediate playback or storage in your announcement system.

GET /v1/voices for available voices

Retrieve a list of all available voice presets, their associated languages, and supported output formats. This endpoint allows you to programmatically select from the eight distinct voice styles, ensuring your bus or train announcements match the desired tone.

GET /v1/models for model details

Fetch technical details about the underlying TTS models, including their specific capabilities and pricing tiers. Use this information to decide between the standard "tts-1" and high-definition "tts-1-hd" models based on your audio quality requirements.

Request Parameters

Sound wave illustration for: Request Parameters

The API accepts a simple JSON payload to generate audio. You must specify the model, input text, voice, and format. The request is sent to the speech endpoint with your Bearer token.

Model selection: tts-1 or tts-1-hd

Both "tts-1" and "tts-1-hd" use the same underlying engine and pricing. Choose "tts-1-hd" if you need slightly higher fidelity for public address announcements, but note that processing time may vary slightly.

Input text up to 4096 characters

Each request supports a maximum of 4096 characters, including spaces and punctuation. For longer announcements, split the text into smaller parts, generate each audio segment, and join them in your transport system.

Voice preset selection from 8 options

Select one of eight presets to match your announcement style. Use "atlas" for neutral, clear station updates or "milo" for friendly, conversational messages. All voices support all 23 languages.

  • atlas: neutral, news-style
  • milo: friendly, conversational
  • aria: warm, clear narrator

Response Formats

Sound wave illustration for: Response Formats

Choose the response format that best fits your deployment environment. The API supports MP3, WAV, OPUS, FLAC, and PCM, allowing you to balance file size, quality, and compatibility based on your specific needs.

MP3 for web compatibility

MP3 is the standard choice for web-based applications and general-purpose playback. It offers broad compatibility with almost all browsers, media players, and hardware decoders, making it ideal for quick integration into public announcement systems without additional codec dependencies.

WAV for high-quality playback

WAV provides uncompressed, high-fidelity audio suitable for professional audio equipment or systems requiring lossless quality. Use this format when preserving the exact acoustic details of the synthesis is critical for your transport announcement infrastructure.

OPUS for efficient streaming

OPUS offers efficient compression for scenarios where bandwidth is limited. It maintains good audio quality at lower bitrates, making it suitable for efficient delivery in public transport information systems.

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

VocalPath enforces strict rate limits to ensure stable synthesis for indie transit announcements. Your API key allows up to 60 requests per minute, providing ample headroom for bulk audio generation or high-frequency trigger events in bus or train systems.

New keys start with a conservative limit of 10 requests per minute. This threshold increases automatically after your first top-up, allowing your public address system to process more requests.

60 requests per minute per key

Once your account is active and funded, you can process up to 60 synthesis requests every minute. This capacity supports real-time announcement loops or batch processing of stop announcements without hitting bottlenecks.

This limit applies per API key, so you can rotate keys if your architecture requires parallel processing beyond the per-key threshold.

  • Standard limit: 60 requests/minute
  • Applies per active API key
  • Automatic increase after first top-up

10 requests per minute initially

New API keys begin with a 10 requests per minute limit. This protects the infrastructure while you integrate the SDK or test your announcement logic.

The limit lifts to 60 requests per minute after your first top-up via USDT on TRON.

No manual verification or support ticket is required to unlock the higher tier.

Queue processing under load

Requests are processed sequentially under load, meaning longer texts may take time to synthesize. Short phrases typically generate in a few seconds.

If your system sends more requests than the limit, extra requests queue automatically. They process in order once capacity is available, ensuring no announcement is lost.

Typical generation speed is roughly 25 characters per second, which aligns with real-time speech for long texts.

Rate Limits and Quotas

Error Handling

Sound wave illustration for: Error Handling

Synthesis failures return specific HTTP status codes to indicate the issue. If the request exceeds the character limit or encounters an invalid voice, the API responds with a 400 or 422 error. You can inspect the response body for a clear message describing the failure reason, allowing your application to handle the error gracefully without guessing.

HTTP status codes for failures

Common errors include 400 for bad requests (e.g., missing input), 401 for unauthorized access, and 429 for rate limit exceeded. A 500 error indicates a server-side issue. Always check the status code first to determine if the error is client-side or server-side.

  • 400: Invalid parameters
  • 401: Invalid API key
  • 429: Rate limit exceeded
  • 500: Internal server error

Retry logic for transient errors

For 500 and 503 errors, implement exponential backoff retries. These errors are often temporary and may resolve quickly. Avoid immediate retries to prevent overwhelming the server, especially when you are near your 60 requests per minute limit.

Charge refund on synthesis failure

If a request fails during synthesis, the charge is returned in full. You do not lose credit for failed attempts. This ensures you only pay for successful audio generations. Check your dashboard balance after a failure to confirm the refund.

Code Examples

Sound wave illustration for: Code Examples

To integrate VocalPath, you can use standard HTTP requests or the official OpenAI SDKs. The API accepts JSON payloads with your text, voice selection, and desired audio format.

cURL command for first request

Send a direct POST request to the speech endpoint. Replace YOUR_API_KEY with your dashboard key and adjust the voice or format as needed.

  • POST https://api.play2739.com/v1/audio/speech
  • Authorization: Bearer YOUR_API_KEY
  • Content-Type: application/json

Python OpenAI SDK integration

Use the official OpenAI SDK by pointing base_url to our API. This allows compatibility with existing Python TTS workflows by changing the base URL.

  • pip install openai
  • from openai import OpenAI
  • client = OpenAI(base_url="https://api.play2739.com/v1", api_key="YOUR_API_KEY")

Node.js fetch example

For JavaScript environments, use the native fetch API. Send the JSON body with your text and voice parameters to receive the audio file directly.

Language Configuration

Sound wave illustration for: Language Configuration

VocalPath intelligently guesses the language from the input script, defaulting to English for Latin characters. This automatic detection simplifies integration, allowing your announcement systems to handle mixed inputs without manual configuration for common use cases.

Manual ISO code override

For precise control, pass the language parameter with a specific ISO code. This is essential when the text is in a non-English Latin-script language (e.g., German or Dutch) to prevent incorrect English voice synthesis.

Supported 23 languages

Every voice preset supports all 23 languages, ensuring consistent audio quality across your global network. Unsupported languages include Vietnamese, Indonesian, Thai, Ukrainian, Romanian, Czech, and Bengali.

  • Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi
  • Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, Turkish

Automatic language detection

The API analyzes the character set to determine the appropriate voice processing. If the language field is omitted, the system assumes English for Latin scripts, ensuring immediate functionality for standard English announcements.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Generate short phrases like "Next stop: Central Station" to check clarity.

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. ISO 639 language codes
  3. Creative Commons Attribution 4.0
  4. LibriTTS-R paper (arXiv 2305.18802)
  5. curl documentation
  6. W3C WAI: making audio and video accessible
  7. LibriVox public-domain audiobooks
  8. Node.js documentation
  9. TRON developer hub: TRC-20
  10. Tether (USDT)
  11. FFmpeg documentation
  12. LibriTTS-R corpus (OpenSLR 141)

More on this site