API Documentation for Text-to-Speech Integration

By M2Cusi editorial team · Updated 2026-11-19

This documentation details the integration of the LessonSpeak text-to-speech API, designed specifically for educational tools used by schools and teachers. It covers the technical requirements for generating audio from text, including request structures, supported models, and voice selection. The guide ensures educators can reliably produce licensable audio files for their instructional materials using standard preset voices.

Readers will find precise specifications for API endpoints, authentication methods, and rate limits. The page clarifies that the service uses eight licensed preset voices rather than custom voice cloning, ensuring clear consent and data rights for educational content. It also explains audio formats, error handling, and refund policies for failed requests, providing a complete reference for technical implementation.

API Documentation for Text-to-Speech Integration

Frequently asked questions

How do I get an API key?

Navigate to /get-api-key/ and sign in using Google or an email password. The page displays your active key, balance, and usage statistics. Accounts are specific to this site. A free trial of $0.50 is granted for Google sign-ins, valid for seven days.

Can I rotate my API key?

Yes, you can issue a new key at any time from the dashboard. When a new key is generated, the previous one stops working immediately. This ensures secure access control for your educational applications without needing to wait for expiration periods.

What is the base URL?

The API base URL is https://api.m2cuci.info/v1. Use this for all endpoints, including POST /v1/audio/speech for generation and GET /v1/voices for metadata. Ensure your requests target this specific domain to avoid connectivity issues with the LessonSpeak service.

Do I need the OpenAI SDK?

You do not need the OpenAI SDK, but you can use it. You can use any HTTP client or the official OpenAI SDK by changing the base_url to our endpoint. The request shape matches the OpenAI speech endpoint, allowing easy integration into existing workflows.

What is the character limit?

Each request supports up to 4096 characters in the input field. This limit applies to the text payload sent in a single API call. For texts exceeding this length, you must split the content into smaller parts and join the resulting audio files.

How do I set the language?

Include the optional 'language' field with an ISO code in your request. If omitted, the system guesses the language, defaulting to English for Latin script. Explicitly setting the language ensures accurate pronunciation for non-English texts, such as German or Japanese.

What formats are supported?

The API supports mp3, wav, opus, flac, and pcm response formats. Select the format that best suits your educational platform’s requirements. MP3 is suitable for web playback, while WAV or FLAC may be preferred for high-quality archival or printing purposes.

How fast is the generation?

Generation is roughly real-time on long texts, processing about 25 characters of text per second. Short phrases may take a few seconds. Requests are processed sequentially, so high load may introduce queue delays. Plan your integration accordingly to handle potential waiting times during peak usage.

What if I hit the rate limit?

The limit is 60 requests per minute per key, or 10 per minute before the first top-up. Exceeding this may delay processing. Implement exponential backoff in your application to handle temporary throttling gracefully without losing generated audio data or incurring unnecessary charges.

How do I handle errors?

Failed requests are free, with charges returned in full if synthesis fails. Monitor HTTP status codes and response bodies for error details. Ensure your text input is within limits and the API key is valid. Failed attempts do not consume your character balance.

Is the API RESTful?

The API uses standard HTTP methods. Use POST for generating speech and GET for retrieving voices or models. Authentication is handled via the Authorization header. This structure allows easy integration with standard web frameworks and educational tooling.

Can I use curl?

Yes, curl is fully supported. The /get-api-key/ page provides a ready-to-use curl example. You can send JSON payloads with your API key in the header. This makes it easy to test the endpoint directly from the command line or scripts.

Do I need to split long texts?

Yes, if your text exceeds 4096 characters, you must split it into parts. Generate audio for each part separately and join the resulting files. This ensures compliance with the single-request character limit while allowing you to create complete audio for longer educational materials.

How do I verify the audio format?

Specify the desired format in the 'response_format' field of your request. The API returns the audio file in the requested format, such as mp3 or wav. Check the response headers and content type to confirm the format matches your educational platform’s requirements.

First request

curl

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

Getting Started

Sound wave illustration for: Getting Started

To begin using LessonSpeak, educators must create an account via the /get-api-key/ page using either Google or an email password. This account is specific to m2cuci.info and provides access to the TTS API tailored for school materials.

Account Creation

Account Creation

Registration is required to obtain an API key. Accounts created with Google receive a $0.50 free trial valid for 7 days, while email-based accounts start with zero balance. This allows methodologists to test the API before integrating it into lesson plans.

  • Google sign-in includes a 7-day trial credit.
  • Email sign-in requires manual top-up via USDT (TRC-20).

API Key Generation

API Key Generation

Upon successful registration, the system issues a single active API key. This key authenticates all requests to the endpoint https://api.m2cuci.info/v1. The key format begins with 'tts-'. Educators should copy this key securely from their dashboard.

Key Management

Each account holds only one active key. If a key is compromised or rotated, issuing a new key immediately invalidates the old one. This ensures that only authorized school devices or servers can access the generated audio files.

Authentication

Sound wave illustration for: Authentication

Authentication for the LessonSpeak API relies on a single active Bearer token per account. This key is issued upon registration and must be included in every request header as Authorization: Bearer <your_key>. The token authenticates your identity and tracks usage against your account balance.

Bearer Token Usage

Include the token in the Authorization header of each POST request to https://api.m2cuci.info/v1. Ensure no extra spaces are present. The token grants access to all endpoints, including speech generation and voice listing.

Key Revocation

You may generate a new key at any time via the dashboard. Upon issuing a new key, the previous one becomes invalid immediately. This allows you to revoke access if a key is compromised without affecting other settings.

Single Key Limit

Each account maintains only one active key at a time. Unlike systems with multiple scoped keys, you must replace the existing key entirely. This simplifies management for educational institutions deploying the API across various teaching tools.

Endpoint: Speech Generation

Sound wave illustration for: Endpoint: Speech Generation

The core functionality is delivered via a standard POST request to the speech generation endpoint. This endpoint accepts JSON payloads containing the text to be converted and the desired voice parameters, returning an audio file directly in the response body. The structure mirrors the OpenAI speech endpoint, allowing educators to use existing OpenAI SDKs by simply adjusting the base URL to https://api.m2cuci.info/v1.

This endpoint is the primary interface for integrating LessonSpeak’s text-to-speech capabilities into digital textbooks, learning management systems, or accessibility tools. It handles the conversion of up to 4096 characters per request, ensuring that educational content remains consistent and licensable for classroom use without requiring complex middleware.

POST Request Structure

Send a JSON object to the endpoint with the necessary parameters. The request must include the authentication token in the header and the text input in the body. The system processes the text sequentially, generating audio that respects the specified language and voice characteristics.

The response returns the audio file directly, allowing immediate playback or storage in your educational database. Ensure that the input text does not exceed the 4096-character limit per request to avoid truncation.

  • Endpoint: POST https://api.m2cuci.info/v1/audio/speech
  • Header: Authorization: Bearer tts-<your-key>
  • Body: JSON object with model, input, voice, etc.

Required Fields

The request must include the model field, which can be set to either tts-1 or tts-1-hd. Both models use the same engine and pricing structure, so the choice depends on your quality preference rather than cost.

The input field contains the text to be synthesized, limited to 4096 characters. Spaces and punctuation count toward this limit. Ensure that the text is properly formatted to avoid any synthesis errors.

  • model: "tts-1" or "tts-1-hd"
  • input: string, max 4096 characters

Optional Parameters

The voice parameter selects from eight presets, such as aria for warm narration or atlas for neutral news-style delivery. The response_format can be set to mp3, wav, opus, flac, or pcm, depending on your integration needs.

The speed parameter allows adjustment between 0.25 and 4.0 times the normal rate. The language parameter is optional but recommended for non-English Latin-script text to ensure accurate pronunciation, as the system defaults to English for Latin scripts.

  • voice: one of 8 presets
  • response_format: mp3, wav, opus, flac, pcm
  • speed: 0.25–4.0
  • language: optional ISO code

Supported Models

Sound wave illustration for: Supported Models

The API supports two model variants, tts-1 and tts-1-hd, which utilize the same underlying synthesis engine. Both models accept identical input parameters and produce audio files with the same character limits and voice presets. The choice between them depends solely on the desired audio fidelity versus processing speed for your educational content.

tts-1 Model

The tts-1 model provides standard quality audio suitable for most classroom applications, such as reading textbooks or creating simple audio guides. It processes requests efficiently, maintaining roughly real-time generation speeds for long texts.

tts-1-hd Model

The tts-1-hd model offers enhanced audio clarity, making it ideal for language learning materials where phonetic precision is critical. It is particularly useful for generating high-quality narration for detailed instructional videos or complex linguistic examples.

Price Difference

Both models are priced identically at $0.01 per 1,000 characters. There is no cost premium for selecting the hd variant, allowing educators to experiment with higher quality audio without increasing their API budget.

Usage is billed per character, including spaces and punctuation. Failed requests incur no charge, ensuring you only pay for successfully generated audio files.

Voice Selection

Sound wave illustration for: Voice Selection

LessonSpeak provides eight preset voices generated from licensed LibriTTS-R recordings, ensuring clear, licensable audio for educational materials. Each voice is a distinct preset; we do not offer custom voice cloning or uploads of teacher-specific voices, maintaining consistency and predictable data rights for schools.

8 Preset Voices

Select from four female voices (Aria, Nova, Luna, Sage) and four male voices (Felix, Milo, Atlas, Orion). Any voice supports all 23 languages, though non-English Latin text requires explicit language specification to avoid defaulting to English.

  • Female: Aria, Nova, Luna, Sage
  • Male: Felix, Milo, Atlas, Orion

Voice Characteristics

Aria offers a warm, clear narrator style suitable for lessons. Luna provides a soft, storytelling tone for reading assignments. Sage is calm and instructional, ideal for procedural explanations. Felix is energetic for promotional school content.

Gender and Tone

Milo delivers a friendly, conversational tone for dialogue simulations. Atlas remains neutral for news-style readings. Orion provides a deep, documentary style. Nova is bright and upbeat for engaging introductions.

Voice Selection

Audio Formats

Sound wave illustration for: Audio Formats

The API supports five standard audio output formats to suit different educational delivery needs. You can choose between lossy compression for efficient delivery or lossless quality for archival purposes. All formats include an inaudible watermark identifying the file as synthetic speech.

Select the format based on your learning management system’s compatibility and storage constraints. MP3 and Opus are suitable for web delivery, while WAV and FLAC preserve maximum audio fidelity for professional materials.

MP3 Format

MP3 is a widely supported format for web-based educational tools. It offers a good balance between file size and audio quality, making it ideal for streaming lessons over standard school networks.

  • Default format for most web integrations
  • Small file size reduces bandwidth usage

WAV Format

WAV provides uncompressed, high-quality audio suitable for professional publishing or archival. Use this format when you need lossless fidelity for printed educational materials or high-end audio stations.

  • Uncompressed quality
  • Ideal for archival storage

Opus, FLAC, PCM

Opus offers efficient compression for low-bandwidth environments. FLAC provides lossless compression for high-quality storage. PCM delivers raw, uncompressed audio data for direct processing in specialized educational software.

  • Opus: efficient streaming
  • FLAC: lossless compression
  • PCM: raw data

Rate Limits and Performance

Sound wave illustration for: Rate Limits and Performance

LessonSpeak’s API enforces a standard rate limit of 60 requests per minute per active key. This threshold supports generation for classroom materials.

Initial Limit

New accounts begin with a reduced limit of 10 requests per minute. This constraint applies until the first top-up is processed. Once a minimum deposit of $5 USDT is confirmed on the TRON network, the limit automatically increases to the standard 60 requests per minute.

Queue Processing

Requests are processed sequentially rather than in parallel. Under normal load, generation takes roughly real time (approximately 25 characters per second). However, during periods of high demand, subsequent requests may wait in a queue before synthesis begins, potentially extending total processing time for large batches.

  • Processing is sequential, not parallel.
  • Standard speed is ~25 chars/sec.
  • Queues may form under load.

60 Requests Per Minute

Error Handling

Sound wave illustration for: Error Handling

Failed synthesis requests are refunded in full, ensuring you are not charged for unusable audio files. This policy applies automatically, so you can verify your balance after any failed attempt without manual claims.

Failed Request Refunds

Any request that fails to produce audio results in a complete credit reversal. You are billed only for successfully generated files, protecting your budget during integration testing or unexpected API instability.

Common Error Codes

We return standard HTTP status codes to indicate request status. A 400 error typically indicates invalid JSON structure or missing required fields like 'input' or 'voice'. Ensure your payload matches the strict schema to avoid rejection.

Retry Logic

For transient errors (5xx), implement exponential backoff with jitter. Since requests are queued sequentially, brief delays often resolve temporary congestion. Do not retry failed 400 errors immediately, as the input remains invalid.

  • Use exponential backoff for 5xx errors.
  • Retry immediately for 429 Rate Limit errors.
  • Do not retry 400 errors without correcting the payload.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. The algorithm learns pitch, pacing, and emotional inflection from this data.

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. openai-node on GitHub
  3. Python documentation
  4. ISO 639 language codes
  5. openai-python on GitHub
  6. LibriVox public-domain audiobooks
  7. OpenAI API reference: create speech
  8. Creative Commons Attribution 4.0
  9. FFmpeg documentation
  10. IETF RFC 7845: Ogg Opus
  11. TRON developer hub: TRC-20
  12. LibriTTS-R corpus (OpenSLR 141)

More on this site