Quickstart Guide: Integrate TTS into Your Pipeline

By SynthScale editorial team · Updated 2026-11-19

This guide provides a concrete starting point for integrating SynthScale’s text-to-speech API into your ML data pipelines. We cover the essential steps to generate auditable, watermarked audio from raw text, optimized for synthetic dataset creation. You will learn how to authenticate, structure requests, and handle responses efficiently without unnecessary abstraction layers.

Designed for AI startups and dataset engineers, this documentation assumes familiarity with standard HTTP workflows. We detail the exact JSON structures, supported formats, and rate limits you need to scale generation reliably. Whether you are using raw cURL or the OpenAI SDK, you will find the specific parameters required to produce high-quality synthetic speech for training models.

Quickstart Guide: Integrate TTS into Your Pipeline

Frequently asked questions

How do I get an API key?

Navigate to /get-api-key/ and sign up using Google or an email and password combination. Once registered, your dashboard displays your active API key, current balance, and usage statistics. You can also generate a new key at any time, which immediately invalidates the previous one.

Can I use the OpenAI Python SDK?

Yes. The API endpoint matches the OpenAI speech request shape. You can use the official OpenAI SDKs by changing the base_url to https://api.nh22.info/v1 and providing your SynthScale key. This allows you to integrate quickly without learning a new library structure.

What is the base URL for the API?

The base URL is https://api.nh22.info/v1. You send POST requests to https://api.nh22.info/v1/audio/speech for synthesis. Additional endpoints include GET /v1/voices for voice details and GET /v1/models for model information.

How many characters can I send per request?

You can send up to 4096 characters per request. For longer texts, split the input into chunks of 4096 characters, generate audio for each part, and join the resulting audio files. This ensures efficient processing within the API limits.

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). Requests are processed sequentially, so exceeding the limit or high load may cause your request to wait in a queue. Failed requests do not consume credit.

Can I rotate my API key?

Yes, you can issue a new key at any time via your dashboard. When a new key is generated, the old one stops working immediately. This allows you to securely rotate credentials without downtime in your integration.

Does the API support streaming audio?

No, the API does not support streaming, WebSocket, or real-time partial audio. You send a text payload and receive the complete audio file in the response. This design is optimized for batch processing and dataset creation workflows.

What audio formats are available?

You can choose from mp3, wav, opus, flac, and pcm formats via the response_format parameter. These formats cover most machine learning ingestion needs. The generated audio files include an inaudible watermark to mark them as synthetic speech.

How do I specify a language?

Use the optional language parameter with an ISO code. If omitted, the system guesses the language from the script, defaulting to English for Latin text. For non-English Latin-script text, explicitly setting the language ensures accurate synthesis.

What is the default voice if none is specified?

The API requires a voice parameter; there is no implicit default. You must select one of the eight presets: aria, nova, luna, sage, felix, milo, atlas, or orion. Each voice is optimized for specific tones like narration or conversation.

Can I change the speed of the audio?

Yes, use the speed parameter with a value between 0.25 and 4.0. This allows you to adjust the playback rate to fit your dataset requirements. Typical speed is roughly real time on long texts (about 25 characters of text per second of generation); short phrases take a few seconds.

Are there any SSML tags supported?

No, the API does not support SSML, phoneme dictionaries, or custom pronunciation lexicons. You control pacing and tone primarily through voice selection and speed adjustments. There are no emotion tags. This keeps the integration simple and focused on raw text input.

How do I handle errors in my code?

Monitor the HTTP response status and body for error details. If synthesis fails, the charge is returned in full, so you are not billed for unsuccessful requests. Implement retry logic with exponential backoff to handle temporary queue delays or rate limits.

Is the API endpoint secure?

Yes, use HTTPS for all requests. Authenticate by including your API key in the Authorization header as Bearer tts-... Your input text is used only for generation and not for training. Request metadata is retained for billing purposes.

First request

curl

curl https://api.nh22.info/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.nh22.info/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.nh22.info/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 Keys

Sound wave illustration for: Authentication and Keys

Authentication for the SynthScale API relies on a single active bearer token per account. You generate this key on the /get-api-key/ dashboard after signing in via Google or email. This token authorizes all subsequent requests to the endpoint https://api.nh22.info/v1 and tracks your usage against your available balance.

Generating Your Key

Generating Your Key

Access the /get-api-key/ page to create your initial API key. The dashboard displays your current key, remaining balance, and usage statistics. Keys are tied to your account and can be viewed directly from this interface without additional verification steps.

Authorization Header

Authorization Header

Include your key in the HTTP header for every request. Use the standard Bearer scheme to ensure proper authentication. The header format is Authorization: Bearer tts-<your-key>. Without this header, requests will return a 401 Unauthorized error and incur no charge.

  • Header name: Authorization
  • Scheme: Bearer
  • Format: Bearer tts-<key>

Key Rotation

You can issue a new key at any time via the dashboard. When a new key is generated, the previous one becomes invalid immediately. This allows for seamless rotation without downtime, ensuring that only active keys can access your account resources.

First Request with cURL

Sound wave illustration for: First Request with cURL

To generate your first audio file, send a POST request to the speech endpoint. This basic command demonstrates the minimal payload required to convert text into synthetic speech, returning the audio file directly in the response body for immediate ingestion into your ML pipeline.

Basic Command

Use the following cURL command to send a simple synthesis request. Replace YOUR_API_KEY with your actual key from the dashboard. This command targets the standard endpoint and accepts a short input string.

  • curl -X POST https://api.nh22.info/v1/audio/speech \
  • -H "Authorization: Bearer YOUR_API_KEY" \
  • -H "Content-Type: application/json" \
  • -d '{"model": "tts-1", "input": "Hello world", "voice": "nova"}'

JSON Body Structure

The request body is a standard JSON object. It requires the model identifier (tts-1 or tts-1-hd), the input text (up to 4096 characters), and a voice preset. Optional fields include response_format, speed, and language.

  • model: String. Either "tts-1" or "tts-1-hd".
  • input: String. The text to synthesize.
  • voice: String. One of the 8 available presets.
  • response_format: String. mp3, wav, opus, flac, or pcm.

Response Handling

A successful request returns the audio file directly in the response body with a 200 OK status. The content type matches the requested format (e.g., audio/mpeg). Failed requests return a JSON error object with details on the issue, such as invalid input or rate limits. Failed requests are free.

OpenAI SDK Integration

Sound wave illustration for: OpenAI SDK Integration

The SynthScale API mirrors the OpenAI speech endpoint structure, allowing you to reuse existing client libraries with minimal configuration. By pointing the SDK’s base_url to https://api.nh22.info/v1, you can generate audio files using the same request shape as OpenAI’s tts-1 models.

This approach simplifies integration for AI startups already familiar with OpenAI’s ecosystem. You maintain your preferred language SDK while accessing SynthScale’s auditable, watermarked synthetic speech optimized for ML datasets.

Base URL Configuration

Set your client’s base URL to https://api.nh22.info/v1. This ensures all requests route through SynthScale’s infrastructure while preserving the standard JSON body format expected by OpenAI-compatible clients.

  • Base URL: https://api.nh22.info/v1

Client Initialization

Initialize your OpenAI SDK client using your SynthScale API key. The key format remains tts-..., and authentication is handled via the standard Authorization: Bearer header.

Ensure your SDK version supports the audio/speech endpoint. Since SynthScale uses the same request schema, no custom parsing logic is required for standard text-to-audio requests. The official OpenAI SDKs work by changing base_url to https://api.nh22.info/v1.

  • Auth: Authorization: Bearer tts-<your-key>

Example Code

```python import os from openai import OpenAI client = OpenAI( base_url="https://api.nh22.info/v1", api_key=os.getenv("SYNTHSCALE_API_KEY") ) with client.audio.speech.create( model="tts-1", voice="aria", input="Synthetic speech for ML training." ) as response: response.stream_to_file("output.mp3") `` This Python snippet demonstrates a basic integration. Adjust the voice and input` parameters as needed for your dataset generation pipeline.

Voice Selection and Models

Sound wave illustration for: Voice Selection and Models

Our API provides eight distinct voice presets, each engineered for specific tonal qualities. These voices are based on licensed recordings: LibriTTS-R (CC BY 4.0), from LibriVox public-domain audiobook readings.

Available Voices

Select from four female voices—aria, nova, luna, and sage—or four male options: felix, milo, atlas, and orion. Each voice offers a unique character, from warm narration to deep documentary tones, all supporting 23 languages.

tts-1 vs tts-1-hd

Both models use the same underlying engine and share identical pricing at $10 per million characters. Choose 'tts-1' for standard efficiency or 'tts-1-hd' when higher fidelity is required for sensitive audio training sets.

Voice Characteristics

Voices are static presets; custom voice cloning or emotion tagging is not available. Every generated audio file contains an inaudible watermark to identify synthetic origin, aiding in dataset verification and copyright clarity.

  • 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

Audio Formats and Output

Sound wave illustration for: Audio Formats and Output

The API supports MP3, WAV, Opus, FLAC, and PCM formats to suit different ingestion pipelines. MP3 offers efficient compression for storage, while PCM and WAV provide uncompressed, bit-perfect audio ideal for precise model training. Opus and FLAC offer a middle ground with lossless or near-lossless compression.

Output files are returned directly in the HTTP response body. You do not need to download from a separate URL. This streamlining helps automate high-volume dataset generation without managing temporary storage.

Supported Formats

Choose from MP3, WAV, Opus, FLAC, or PCM based on your model’s requirements. MP3 is efficient for general use, while PCM provides raw data for immediate processing.

  • MP3
  • WAV
  • Opus
  • FLAC
  • PCM

File Sizes

File size varies by format and duration. Uncompressed PCM files are larger but require no decoding overhead. Compressed formats like MP3 reduce storage costs but add a decoding step in your pipeline.

PCM vs MP3

PCM delivers raw audio samples, ensuring no data loss during transfer. MP3 applies lossy compression, reducing file size compared to PCM. For ML training, PCM ensures bit-perfect input, while MP3 saves bandwidth and storage.

Audio Formats and Output

Rate Limits and Quotas

Sound wave illustration for: Rate Limits and Quotas

SynthScale enforces a strict rate limit of 60 requests per minute per API key. This ceiling ensures stable synthesis for high-volume dataset generation pipelines. Requests are processed one after another, so under load a request may wait in a queue.

New accounts start with a lower limit of 10 requests per minute. This restricts usage until you perform your first top-up. Once you add USDT (TRC-20) to your balance, the limit automatically increases to 60 RPM, allowing for faster processing of large character sets.

60 Requests Per Minute

The standard limit is 60 requests per minute for all funded accounts. This allows for steady throughput when generating audio files for ML training datasets. Each request can handle up to 4096 characters, so 60 RPM supports significant daily volume.

  • Standard limit: 60 RPM
  • Applies per API key
  • Applies to all models

Initial 10 RPM Limit

Accounts without a top-up are capped at 10 requests per minute. This lower limit prevents abuse during the free trial phase. Once you transfer a minimum of $5 in USDT, the limit rises immediately.

  • Unfunded accounts: 10 RPM
  • Capped during trial period
  • Limits scale with funding

Handling Throttling

If you exceed the limit, the API returns a 429 Too Many Requests error. You should implement exponential backoff in your client. Retry logic should account for the queue processing time, as short phrases may take a few seconds to synthesize.

  • Return code: 429
  • Implement exponential backoff
  • Check Retry-After header

Error Handling and Status Codes

Sound wave illustration for: Error Handling and Status Codes

API responses include standard HTTP status codes alongside specific error codes to help you diagnose synthesis failures quickly. Common issues include invalid character limits, unsupported voice IDs, or temporary backend queues causing 429 Too Many Requests errors.

Common Errors

400 Bad Request indicates malformed JSON or missing required fields like input. 401 Unauthorized occurs if the Authorization header is missing or the key is invalid. 429 Too Many Requests triggers when you exceed the 60 RPM limit per key.

  • 400: Invalid JSON or missing model field.
  • 401: Invalid or expired API key.
  • 429: Rate limit exceeded (60 req/min).

Retry Logic

For transient 5xx errors or 429s, implement exponential backoff. Start with a 1-second delay and double it up to three retries. Avoid immediate retries, as the queue may still be processing your previous request.

  • Retry 429 errors with exponential backoff.

Billing Errors

402 Payment Required appears if your balance is insufficient for the request. Failed synthesis requests are refunded, so a 5xx error does not deduct from your balance. Check your balance regularly via the dashboard or API.

  • 402: Insufficient funds for the request.
  • Refunds are automatic for failed synthesis.
  • Balance does not expire.

Advanced Parameters

Sound wave illustration for: Advanced Parameters

Beyond basic synthesis, fine-tuning speed and language ensures your synthetic datasets match specific acoustic profiles or linguistic requirements without post-processing overhead.

Precise control over these parameters allows you to generate consistent training data at scale, reducing the need for manual audio normalization in your ML pipelines.

Speed Control

Adjust speech rate from 0.25 to 4.0 using the speed parameter. This allows you to adjust the playback rate to fit your dataset requirements.

Speed adjustments are applied in real-time during synthesis, preserving natural prosody without requiring external audio tools.

  • Range: 0.25 to 4.0

Language Codes

Set the language field with an ISO code (e.g., 'de', 'fr', 'ja') to enforce specific pronunciation. Without this, the system guesses based on script, defaulting to English for Latin text.

This is critical for multilingual datasets to prevent accent leakage when training models on specific languages like Korean or Arabic.

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

Input Text Limits

Each request accepts up to 4096 characters. For longer texts, split your corpus into chunks, synthesize them individually, and join the resulting audio files.

Spaces and punctuation count toward this limit, so plan your chunking strategy accordingly to avoid truncation in your training data.

  • Max: 4096 characters per request

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. This voice is excellent for narrative datasets, audiobooks, or any application requiring expressive, fluid speech patterns.

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

More on this site