Frequently asked questions
What is a text-to-speech API?
It is a cloud service that converts text into audio files. You send text via a POST request, and receive an audio response. This allows your Python application to generate synthetic speech dynamically without managing audio files manually, ideal for LMS content.
How does Python interact with the API?
Python sends a JSON payload to the endpoint using HTTP requests. You provide the text, voice, and format. The API returns the audio file directly in the response. This simple request-response cycle integrates easily into any Python workflow for generating educational audio.
Is the API RESTful?
Yes, it uses standard HTTP methods. You POST to /v1/audio/speech for generation and GET /v1/voices to list options. It follows REST principles, making it predictable and easy to integrate into Python applications using standard HTTP libraries without complex protocol handling.
Do I need a special library for Python?
No special library is required. You can use standard libraries like requests or httpx. While OpenAI SDKs work by changing the base URL, plain HTTP requests are sufficient. This keeps your dependencies minimal and reduces potential conflicts in your Python environment.
Can I use the API in a Django app?
Yes, it works perfectly with Django. You can call the API from Django views or Celery tasks. Since it is a standard HTTP API, you can integrate it into your existing Django project structure to generate audio for online courses on the fly.
How is authentication handled?
Authentication uses a Bearer token in the Authorization header. You obtain this key from your account dashboard. Include it in every request to verify your identity and track usage. Each account has one active key, which can be rotated if needed.
What is a bearer token?
It is a string starting with 'tts-' that acts as your password. You include it in the HTTP header as 'Authorization: Bearer tts-...'. This token authenticates your requests and links usage to your account balance for billing purposes.
Can I send audio back to the client?
Yes. The API returns the audio file in the response body. In Python, you can read this binary data and save it to a file. This allows seamless delivery of generated speech to end-users.
How do I handle errors in Python?
Check the HTTP status code in the response. If synthesis fails, the charge is returned. You should handle non-200 responses by logging the error and retrying if appropriate. Failed requests do not consume your character balance, ensuring cost efficiency.
Is the API synchronous or asynchronous?
It is synchronous. You send a request and wait for the audio file. Processing happens sequentially, so under load, requests may queue. For long texts, split them into parts and join the resulting audio files after each request completes.
Can I process multiple texts at once?
You can send multiple requests concurrently from Python using threads or asyncio. However, the API processes requests one after another. High concurrency may increase latency. Monitor your rate limit of 60 requests per minute to avoid throttling.
What is the maximum input size?
Each request supports up to 4096 characters. If your text exceeds this, split it into smaller chunks. Generate audio for each part and join the files. Spaces and punctuation count toward this limit, so plan your splits accordingly.
Do I need to install third-party packages?
No, you do not need specific packages. Standard Python libraries like requests or urllib work fine. You can also use the OpenAI Python library by adjusting the base URL. This flexibility allows you to choose the best tool for your stack.
Is the API suitable for production?
Yes, it is designed for production use. It provides clear pricing and no hidden fees. With proper error handling and rate limit management, it serves as a robust solution for generating audio content at scale.
Understanding the API Concept
Our text-to-speech API follows a simple request-response model: you send text, and we return an audio file. This synchronous approach fits well into standard Python workflows without requiring complex streaming setup. The endpoint is POST https://api.okwe.info/v1/audio/speech, mirroring the structure familiar to OpenAI SDK users.
Request-Response Model
Send a JSON payload with your text and voice preference. Receive a direct audio file response. This predictability helps product teams integrate TTS into LMS modules with minimal code changes.
JSON Body Structure
The request body includes fields like model, input, voice, and response_format. These fields map directly to standard parameters, allowing you to use the official OpenAI Python SDK by simply adjusting the base_url to https://api.okwe.info/v1.
- model: 'tts-1' or 'tts-1-hd'
- input: your text content
- voice: one of 8 presets
- response_format: mp3, wav, opus, flac, or pcm
Audio File Delivery
The API returns the synthesized audio directly in the response body. No temporary files or separate download steps are needed. You can immediately save the binary data to your LMS asset library.
Why Python for TTS?
Python is the standard language for educational content pipelines. Its rich ecosystem includes robust HTTP clients and audio processing libraries that simplify the integration of synthetic speech into learning modules without requiring complex infrastructure setup.
Rich Ecosystem
Python provides mature libraries like requests or httpx for reliable API communication. These tools handle JSON serialization and binary audio responses seamlessly, allowing product teams to focus on content logic rather than networking details.
- Native JSON support for easy payload construction
- Strong community libraries for audio file handling
- Built-in string manipulation for character counting
OpenAI SDK Compatibility
Since our API mirrors the OpenAI speech endpoint structure, you can use the official OpenAI Python SDK with minimal changes. Simply adjust the base_url to https://api.okwe.info/v1 and provide your API key.
- Drop-in replacement for existing OpenAI integrations
- Familiar method signatures (
client.audio.speech.create) - Standardized error handling patterns
Easy Scripting for LMS
Python scripts can easily loop through course modules, generating audio for each text segment. You can automate the entire batch process, from text validation to file saving, ensuring consistent audio delivery across all learning units.
Data Flow in LMS
In an LMS workflow, text input begins as structured content within your learning modules. This text is passed directly to the TTS API, which processes the request and returns an audio file ready for playback in your course player.
The system handles the conversion seamlessly, ensuring that your educational materials are delivered as high-quality audio without manual intervention. This process supports both short phrases and longer lessons, adapting to the specific needs of your students.
Text Input
Your LMS sends text to the API via a POST request. The input field accepts up to 4096 characters per request, covering the body of your lesson or quiz question. Spaces and punctuation count toward this limit.
API Processing
The API receives the JSON body containing the model, voice, and language parameters. It synthesizes the speech using the selected engine and returns the audio file. If the request fails, no charge is applied.
Audio Output
The response contains the audio file in your chosen format (mp3, wav, opus, flac, or pcm). This file is immediately available for embedding in your LMS player or downloading for offline use.
Authentication
Authentication secures your API access using a single active Bearer token. This token authenticates every request to the speech endpoint, ensuring that usage is correctly attributed to your account for billing and rate-limiting purposes.
Bearer Token
Your API key acts as the Bearer token, prefixed with 'tts-'. It is the sole credential required to authorize requests. You receive this key upon account creation or key rotation.
- One active key per account
- Starts with 'tts-'
Authorization Header
Include the token in the HTTP header of every request. Use the format: Authorization: Bearer tts-<your_key>. This standard header ensures secure transmission over HTTPS.
Key Management
You can issue a new key at any time via the dashboard. The old key stops immediately, preventing unauthorized use if compromised. Rotate keys regularly for better security.
Text Processing
Handling text input correctly is essential for accurate audio generation. Our API accepts plain text strings up to 4096 characters per request. Every character, including spaces and punctuation, counts toward your usage and billing.
Long course modules often exceed this limit. You must split the text into smaller chunks, send each chunk to the API, and then join the resulting audio files into a single continuous track.
Character Counting
Calculate the length of your input text before sending it. The API counts every character, so a 4096-character limit means you must truncate or split strings that are longer. This ensures you stay within the single-request boundary.
- Count all characters, including spaces and punctuation.
- Limit each request payload to 4096 characters.
Splitting Long Text
Break long educational content into segments of up to 4096 characters. Use Python string slicing or natural language processing libraries to split at sentence boundaries where possible. This prevents mid-sentence audio cuts and maintains logical flow.
- Split text into chunks of max 4096 characters.
- Preserve sentence structure for natural pauses.
Joining Audio Files
Once you receive audio files for each segment, concatenate them in order. Use libraries like pydub or ffmpeg to merge MP3 or WAV files into a single audio track. This creates a seamless listening experience for your LMS users.
- Merge segments in the correct chronological order.
- Use standard audio libraries for format compatibility.
Voice Selection
Choosing the right voice ensures your course audio sounds professional and engaging. Our API provides eight distinct presets, each crafted for specific narrative styles. Selecting the appropriate voice helps maintain listener engagement across different learning modules.
The voices are based on licensed recordings from LibriTTS-R (CC BY 4.0) and LibriVox public-domain audiobook readings. Every generated file includes an inaudible watermark to mark it as synthetic, maintaining transparency without affecting the listening experience.
Preset Voices
We offer eight voices, split evenly between female and male presets. Each voice has a distinct character, from warm narrators to energetic promo speakers. You can select any voice for any language supported by the API.
The available voices are: Aria, Nova, Luna, and Sage for female tones; Felix, Milo, Atlas, and Orion for male tones. These presets cover a wide range of educational contexts, from soft storytelling to neutral news delivery.
- 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
Voice Characteristics
Each voice is optimized for specific content types. For instance, Atlas provides a neutral tone suitable for news or factual modules, while Luna’s soft style works well for storytelling segments. Felix brings energy to promotional or introductory content.
The audio engine processes text at roughly real-time speed for long texts (about 25 characters per second); short phrases take a few seconds. Short phrases may take a few seconds to generate, but the quality remains consistent.
Matching Tone to Content
Match the voice to your module’s goal. Use Sage for instructional content where clarity is key, or Orion for documentary-style deep dives. Consistent voice selection across a course helps learners recognize the content type.
You can change voices between requests without any additional configuration. This flexibility allows you to create dynamic learning experiences, switching from a friendly conversational tone to a more formal presentation style as needed.
Language Handling
Language handling in our API is precise and flexible, allowing you to control exactly how synthetic speech sounds in your LMS modules. By explicitly defining the language, you ensure consistent pronunciation and intonation, which is critical for educational clarity.
ISO Language Codes
You can pass an optional language field in the request body using standard ISO codes. This ensures the engine applies the correct phonetic rules regardless of the voice preset used.
- Supported languages include Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, and Turkish.
Script Detection
If the language field is omitted, the API guesses the language based on the character script in your input text. Latin script defaults to English, while Cyrillic or Han characters trigger their respective languages automatically.
Default English Fallback
For non-English text using Latin characters, always set the language parameter explicitly. Without it, the system assumes English, which may lead to awkward pronunciation for languages like Dutch or Norwegian.

Error Scenarios
Even robust integrations encounter hiccups. Understanding common error scenarios helps you build resilient LMS audio pipelines that handle interruptions gracefully without failing the entire course module.
Network Issues
If the connection drops, your script should retry with exponential backoff. Since requests are processed sequentially, a temporary network blip might delay audio generation but rarely causes data loss if handled correctly.
- Implement retry logic for 5xx server errors.
- Handle timeouts gracefully by logging the specific request ID.
Invalid Input
Ensure your text stays within the 4,096 character limit. If you exceed this, the API will reject the request, so split your text beforehand as described in the processing section.
- Validate character count before sending.
- Check that the
voiceparameter matches one of the 8 presets.
Rate Limiting
You are limited to 60 requests per minute per key (10 before the first top-up). If you hit this limit, your requests will queue or fail temporarily. Monitor your usage dashboard to stay within bounds.
- Track requests per minute in your Python script.
- Pause synthesis jobs if the limit is reached to avoid wasted credits.
Performance Considerations
Synthesis speed varies by content length and current load. Short phrases take a few seconds, while long texts generate at roughly real-time speed (25 characters per second). Requests are processed sequentially, so under heavy load, a request may wait in a queue before processing begins.
Understanding these timing characteristics helps product teams plan audio generation for their online courses effectively.
Generation Speed
Synthesis is not instantaneous. Short phrases typically require a few seconds to complete. For longer texts, the generation rate is approximately real-time, producing about 25 characters of text per second of audio.
Queue Wait Times
Requests are processed one after another. If many users are generating audio simultaneously, your request may wait in a queue before it begins processing. This delay is normal and depends on the current server load.
Parallel Requests
You can send multiple requests concurrently to improve throughput. However, each request still follows the sequential processing rule internally. Monitor your usage to stay within the 60 requests per minute limit per key.
Security
Security is foundational for protecting your educational content and API usage. By keeping credentials secure and understanding how data flows, you ensure that your LMS integration remains reliable and private throughout the production lifecycle.
API Key Protection
Use environment variables to store your Bearer token rather than hardcoding it. Rotate keys immediately if exposure is suspected, as the old key stops working instantly. One active key per account simplifies management without compromising security.
- Store keys in
.envfiles - Rotate keys via the dashboard
- Use one key per account
HTTPS Usage
All requests to https://api.okwe.info/v1 use HTTPS by default. This ensures your API key and input text are encrypted in transit between your Python scripts and our servers, preventing interception during transmission.
No Data Storage
Input text is used solely to generate the audio file and is not used for training. Generated audio is returned in the response and not stored. Only request metadata like time and character count is kept for billing purposes.
- No text training
- No audio storage
- Metadata kept for billing
Testing Strategies
Testing ensures your LMS audio pipeline works reliably before students encounter errors. Start by verifying small samples to confirm voice quality and language detection, then scale up to batch processing for longer course modules.
Verify output formats match your player requirements and monitor usage metrics to stay within rate limits. This approach prevents costly surprises during peak learning periods.
Small Samples
Send short phrases (under 100 characters) to validate voice selection, speed, and format output. This confirms that text-to-speech conversion works before processing entire lessons.
- Test each of the 8 preset voices with sample text
- Verify mp3, wav, opus, flac, and pcm outputs
- Check language detection accuracy for non-English Latin text
Batch Testing
Process multiple requests sequentially to simulate real LMS workflows. Monitor character counts against your 4096-character limit and verify that split-and-join logic works correctly.
Track request timing to ensure queue wait times remain acceptable during bulk generation.
- Simulate 10-20 lesson requests in sequence
- Verify character counting includes spaces and punctuation
- Confirm audio files join seamlessly without gaps
Format Verification
Ensure generated audio files are playable and match the requested response_format. Use metadata checks to confirm file integrity before storing in your LMS.
Verify that no synthetic watermarks interfere with your audio player if that matters for your use case.
- Validate file headers for mp3/wav/opus/flac/pcm
- Check file size matches expected duration
- Confirm no playback errors in standard players
Deployment Tips
Deploying your TTS integration in production requires secure credential management and robust observability. By isolating configuration from code and tracking usage metrics, product teams can ensure reliable audio generation for their online courses without unexpected downtime or budget overruns.
Environment Variables
Store your API key in environment variables rather than hardcoding it in your Python scripts. This prevents accidental exposure when sharing code or deploying to different LMS environments. Use libraries like python-dotenv to load keys securely from a .env file during initialization.
- Use
os.environ['TTS_API_KEY']for runtime access. - Never commit the
.envfile to version control. - Rotate keys immediately if exposed via the dashboard.
Error Logging
Log both successful requests and failures to diagnose issues quickly. Capture the HTTP status code, request ID, and any error messages returned by the API. This helps distinguish between network timeouts, invalid inputs, or rate limit hits, allowing your team to adjust retry logic appropriately.
- Log status codes: 200, 400, 429, 500.
- Record character count and voice used for each request.
- Include timestamps to identify peak load periods.
Monitoring Usage
Track your character consumption and API key status regularly. Since you are charged per 1,000 characters, monitoring usage helps you predict costs and avoid running out of credit during course production. Check your balance via the dashboard or API to ensure continuous audio generation for learners.
- Check balance before large batch jobs.
- Monitor rate limits (60 requests/minute).
- Set alerts for low credit thresholds.
Listen to the 8 voices
Each sample below was generated by this API from the same sentence. This ensures consistent acoustic properties across all eight presets, making them reliable for educational content.
23 languages
Any voice speaks any of these languages.
Sources and further reading
- Wikipedia
- LibriTTS-R paper (arXiv 2305.18802)
- LibriVox public-domain audiobooks
- OpenAI API reference: create speech
- IETF RFC 7845: Ogg Opus
- MDN: Web Speech API
- LibriTTS-R corpus (OpenSLR 141)
- FFmpeg documentation
- curl documentation
- Creative Commons Attribution 4.0
- openai-python on GitHub
- W3C WAI: making audio and video accessible
