How to Integrate Our Text-to-Speech API in Python Applications?

By VoiceLingo editorial team · Updated 2026-11-19

This guide shows indie developers how to integrate VoiceLingo’s text-to-speech API into Python applications for language learning tools. You will learn to generate clear audio from text using the OpenAI-compatible endpoint, handling voices optimized for educational content. The process covers everything from obtaining your API key to managing long texts and speed adjustments.

We provide practical, step-by-step instructions with concrete Python examples. You will see how to install dependencies, construct requests, and handle responses without unnecessary complexity. The guide focuses on fair pricing, reliable integration, and specific workflows tailored for building engaging language learning experiences.

How to Integrate Our Text-to-Speech API in Python Applications?

Frequently asked questions

What is TTS API?

It is a cloud API where you send text and receive an audio file. Send a POST request to the /v1/audio/speech endpoint with your text, voice, and format. It uses the same request shape as the OpenAI speech endpoint, allowing you to use standard HTTP libraries or the OpenAI SDK by changing the base URL.

What is Google TTS API?

Google TTS is a separate service by Google that converts text into spoken audio. It is not affiliated with VoiceLingo. Our API offers a similar function but uses different pricing, voices, and infrastructure. We do not provide the Google TTS service, nor do we store or manage Google’s specific keys or quotas.

How does the Google TTS API work?

Google TTS typically works by sending text to their servers, which return an audio file. It often requires specific Google Cloud credentials and may support streaming or SSML. Our API works differently: you send a JSON body with text and voice parameters to our endpoint, receiving a static audio file without streaming support.

Is the Google TTS API free?

Google offers a free tier with limited characters, but charges apply after that. Our pricing is strictly usage-based at $10 per million characters. We do not offer a free tier beyond a $0.50 trial for new accounts. Payments are made via USDT on the TRON network, not through Google’s billing system.

What is the Google TTS API Python library?

This refers to Google’s official client library for accessing their TTS service. We do not provide an official SDK. You can use the OpenAI Python SDK by pointing it to our base URL, or use standard libraries like requests. Our API is compatible with the OpenAI SDK request format for ease of integration.

How to use Google TTS API in Python?

You would typically authenticate with Google Cloud credentials and call their specific endpoints. For our API, install the OpenAI SDK, set the base URL to https://api.fodmod.info/v1, and use the standard speech endpoint. Pass your API key in the Authorization header and send text via the JSON body as you would for OpenAI.

What are the Google TTS API limits?

Google imposes specific character limits and request quotas per project. Our limits are 60 requests per minute per key (10 before top-up). Each request supports up to 4096 characters. We do not enforce Google’s specific limits, so you should refer to our documentation for our exact rate limits and character constraints.

Does the API support streaming audio?

No, we do not support streaming, WebSocket, or real-time partial audio. The API returns a complete audio file after processing. You must wait for the full response to receive the audio data. This fits well with language learning apps that preload audio files for vocabulary exercises.

What languages are supported?

We support 23 languages: Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, and Turkish. Any voice can speak any of these languages. If the language is not set, it is guessed from the script.

Are the voices human or synthetic?

The voices are synthetic but based on licensed recordings from LibriTTS-R (CC BY 4.0) and LibriVox public-domain audiobooks. Every generated file carries an inaudible watermark marking it as synthetic speech. They are not real-time human recordings but high-quality synthesized audio.

Can I clone my own voice?

No, we do not offer custom voice cloning or uploading your own voice. You must choose from the 8 available presets: Aria, Nova, Luna, Sage, Felix, Milo, Atlas, or Orion. These are fixed voices optimized for different tones, such as warm narration or energetic promo.

What is the price per character?

The price is $10 per 1 million characters, which equals $0.01 per 1,000 characters. Spaces and punctuation count as characters. Failed requests are free, with the charge returned in full. There are no monthly plans or minimum spends, making it cost-effective for indie developers with variable usage.

How does the free trial work?

New accounts signing in with Google receive $0.50 of credit, valid for 7 days, covering about 50,000 characters. Accounts created with email and password start without trial credit. You can top up with USDT on the TRON network to continue using the API. The balance does not expire.

Is my data used for training?

No, your input text is used only to produce the audio and is not used for training. Generated audio is returned in the response and not stored. We keep request metadata like time, characters, and status for billing purposes only. Your data remains private.

Step 1: Get Your API Key

Sound wave illustration for: Step 1: Get Your API Key

To start integrating VoiceLingo’s text-to-speech API into your language learning app, you first need access credentials. Visit the /get-api-key/ page to create your account and retrieve the authentication token required for all API requests.

Your key enables you to send text and receive audio files. Keep this token secure, as it is the sole identifier for your account and billing.

Sign up on the /get-api-key/ page

Navigate to https://fodmod.info/get-api-key/ to begin the process. This page serves as the central hub for managing your account within the VoiceLingo network. You will find the interface to generate your unique API key, view your current balance, and access usage statistics.

Creating an account is the prerequisite step before you can make any API calls. The system links your key directly to your billing and character consumption history.

  • Visit the dedicated sign-up URL
  • Ensure you are on the correct domain
  • Prepare to create a unique account

Choose Google or email signup

You can register using either your Google account or a standard email and password combination. Each method creates an independent account specific to this site. Choose the option that best fits your development workflow.

Accounts created via Google sign-up automatically receive a $0.50 trial credit valid for 7 days. Email-based accounts start with zero credit. This trial allows you to test the API with approximately 50,000 characters before committing funds.

Once signed up, your account is ready for integration. There are no monthly subscriptions or seats to manage, keeping your setup simple for indie development.

  • Google sign-up includes free trial credit
  • Email signup requires manual top-up
  • Independent accounts per site

Copy your Bearer token

After registration, locate your API key on the dashboard. It begins with the prefix tts-. Copy this string exactly, as it will be used in the Authorization: Bearer header of your HTTP requests.

One active key is issued per account. You can issue a new key at any time, which immediately invalidates the previous one. Store your token in your application’s environment variables to keep it secure during development.

  • Key format: tts-...
  • Single active key per account
  • Use environment variables for storage

Step 2: Install Dependencies

Sound wave illustration for: Step 2: Install Dependencies

Before making your first API call, prepare your Python environment. Since we use the same request shape as OpenAI, you can leverage their existing SDKs or standard HTTP libraries to keep integration simple and familiar for your language learning app.

Setting up a clean environment ensures you can manage dependencies without conflicts, making it easier to update your app later as you add new voices or languages to your curriculum.

Install OpenAI Python library

Install the official OpenAI Python library to use the client.speech.create() method. This library handles the JSON serialization and multipart encoding automatically, reducing boilerplate code in your language learning app.

Run pip install openai in your terminal. This gives you direct access to the speech endpoint with minimal configuration changes.

  • pip install openai
  • Supports base_url override
  • Handles JSON body creation

Install requests library for HTTP calls

For more control over raw HTTP responses, install the requests library. This is useful if you prefer manual header management or need to inspect raw byte streams for debugging synthesis issues.

Run pip install requests. This allows you to use requests.post() for direct API communication without the SDK overhead.

  • pip install requests
  • Manual header management
  • Raw byte stream access

Set up your virtual environment

Always use a virtual environment to isolate your project dependencies. This prevents version conflicts between your TTS integration and other libraries in your language learning app.

Create a virtual environment using python -m venv venv and activate it before installing libraries. This ensures reproducible builds when you deploy your app to production servers.

  • python -m venv venv
  • Isolates dependencies
  • Ensures reproducible builds

Step 3: Construct the Request

Sound wave illustration for: Step 3: Construct the Request

To integrate VoiceLingo into your language learning app, start by defining the correct endpoint and authentication structure. This ensures your requests reach the synthesis engine correctly and are recognized as valid.

The API follows a standard JSON shape, making it compatible with common Python libraries. You will send text and voice parameters in a single POST request to receive an audio file.

Define the endpoint URL

Send your synthesis requests to POST https://api.fodmod.info/v1/audio/speech. This endpoint accepts JSON bodies and returns audio files in your chosen format. Use the OpenAI Python SDK by setting the base_url to https://api.fodmod.info/v1 for seamless integration.

Set headers with Authorization token

Include your API key in the Authorization header as a Bearer token. The format is Authorization: Bearer tts-your_key_here. Retrieve this key from your dashboard at /get-api-key/ after signing up.

Create JSON body with text and voice

Construct a JSON object with model (e.g., "tts-1"), input (your text up to 4096 characters), and voice (one of the 8 presets like 'aria' or 'felix'). You can also specify response_format (mp3, wav, etc.) and an optional language code.

  • model: "tts-1" or "tts-1-hd"
  • input: string, max 4096 chars
  • voice: e.g., "nova", "atlas"
  • response_format: "mp3", "wav", "opus"

Step 4: Send the Request

Sound wave illustration for: Step 4: Send the Request

Once your request body is constructed, you send it to the API endpoint. You can use the requests library for direct HTTP calls or the openai Python SDK for a structured approach. Ensure your base URL points to https://api.fodmod.info/v1 so the SDK routes correctly.

Use requests.post() or client.speech.create()

For direct HTTP, use requests.post() with your endpoint URL and headers. If using the OpenAI SDK, initialize the client with your base URL and call client.audio.audio.create(). Pass your model, input text, voice, and format parameters in the request.

  • Use requests.post(url, headers=headers, json=payload)
  • Use client.audio.speech.create(model=..., input=..., voice=...)

Handle the response status code

Check the response status code immediately. A 200 OK indicates success. A 401 error means your API key is invalid or expired. A 429 error indicates you have hit the rate limit of 60 requests per minute. Handle these errors by logging the issue or retrying with backoff.

Extract audio data from response

Upon success, the response contains the audio binary data. With requests, access this via response.content. With the SDK, the response object contains the audio bytes. Save this data directly to a file in your chosen format (mp3, wav, opus, flac, or pcm).

  • Save response.content to a file
  • Use response.audio_bytes from SDK

Step 5: Process the Audio

Sound wave illustration for: Step 5: Process the Audio

After receiving the audio bytes from the API response, you can save the file directly to your project directory. This is ideal for static vocabulary lists where the audio does not change frequently.

You can also play the audio immediately in a web interface or mobile app using standard media players. Storing generated audio locally reduces repeated API calls for common phrases, lowering costs.

Save MP3 file to disk

Write the binary response content to a local file using your preferred I/O method. MP3 is the default format and offers a good balance between quality and file size for language learning apps.

  • Use response.content to get binary data.
  • Save with extensions like .mp3, .wav, or .opus.

Play audio in browser or app

Embed the audio data directly into HTML5 <audio> tags or pass it to native media players. This allows learners to hear pronunciation instantly without waiting for file downloads.

Ensure the audio plays sequentially if you are concatenating multiple short phrases for longer sentences.

Store audio for later use

Store generated files in your application's static assets folder or a cloud storage bucket. This pre-generated approach ensures consistent playback speed and reduces latency for users.

Note that generated audio is not stored by the API, so you must manage your own storage lifecycle.

  • Cache frequent phrases to save API credits.
  • Delete unused audio to manage storage costs.

Step 6: Handle Long Texts

Sound wave illustration for: Step 6: Handle Long Texts

Long texts exceed the 4096-character limit per request. You must split your input text into smaller chunks and process them individually to ensure successful synthesis.

Each chunk generates a separate audio file. The API processes requests sequentially, so longer texts may take time proportional to their length, roughly real-time speed.

Split text into 4096 char chunks

Divide your input text into segments of up to 4096 characters. Ensure boundaries respect word spaces to avoid truncated words in the audio output.

Spaces and punctuation count toward the character limit. Accurate splitting preserves the natural flow of the generated speech for language learning contexts.

  • Limit each segment to 4096 characters.
  • Preserve word boundaries for natural audio.
  • Count spaces and punctuation as characters.

Make multiple API requests

Send each text chunk as a separate POST request to the speech endpoint. The API handles each segment independently, returning individual audio responses.

Rate limits apply per key (60 requests per minute). Monitor your usage to avoid 429 errors during bulk synthesis of long lessons.

  • One request per 4096-character chunk.
  • Monitor rate limits (60 req/min).
  • Each response contains one audio file.

Join audio files sequentially

Combine the returned audio files in the order of the original text chunks. Use a library like pydub or ffmpeg to concatenate the MP3s.

The resulting file plays as a continuous narrative, ideal for delivering complete lessons or articles to your language learning app users.

  • Concatenate files in original order.
  • Use pydub or ffmpeg for merging.
  • Create one continuous audio lesson.

Step 7: Add Speed Control

Sound wave illustration for: Step 7: Add Speed Control

Adjust the speed parameter between 0.25 and 4.0 to control synthesis rate. This feature allows you to tailor audio pacing for different educational contexts, ensuring the speech matches your app’s learning objectives.

Adjust speed parameter 0.25-4.0

Set the speed field in your JSON request body to any value from 0.25 to 4.0. The default is 1.0. Lower values slow down pronunciation, while higher values increase tempo. This works with all 8 voice presets and 23 supported languages.

  • Min speed: 0.25 (very slow)
  • Max speed: 4.0 (very fast)
  • Works with tts-1 and tts-1-hd models

Slower speed for learning comprehension

Use speeds around 0.5–0.75 for new vocabulary or grammar explanations. Slower speech gives learners time to process phonemes and syntax. This is ideal for beginner-level language app modules where clarity matters more than speed.

  • Recommended: 0.5–0.75
  • Best for: new learners
  • Improves pronunciation clarity

Faster speed for review practice

For advanced users or flashcard reviews, set speed to 1.5–2.0. Faster synthesis matches natural conversation flow and helps learners build listening stamina. Use this for established vocabulary where comprehension is already secure.

  • Recommended: 1.5–2.0
  • Best for: review sessions
  • Matches natural speech rhythm
Step 7: Add Speed Control

Step 8: Manage Errors

Sound wave illustration for: Step 8: Manage Errors

Error handling ensures your language learning app remains responsive when the API encounters issues. Properly managing authentication and rate limits prevents abrupt failures during audio generation.

Check for 401 unauthorized errors

A 401 status indicates an invalid or expired API key. Verify your token matches the Bearer format from your account dashboard. Regenerate the key if necessary, noting that the old one stops immediately.

  • Verify token format: Bearer tts-...
  • Check for typos in the key string
  • Regenerate via /get-api-key/ if compromised

Handle 429 rate limit errors

The API allows 60 requests per minute per key (10 before first top-up). Exceeding this triggers a 429 error. Implement exponential backoff or queue requests to stay within limits without blocking the user interface.

  • Limit: 60 req/min (10 pre-top-up)
  • Implement exponential backoff on 429
  • Queue requests during high load

Retry failed requests gracefully

Not all failures are permanent. Network glitches or temporary server issues may cause transient errors. Retry failed requests with a short delay, but avoid infinite loops. Remember that failed synthesis requests are free, so retrying does not incur extra cost.

  • Retry transient network errors
  • Exponential backoff recommended
  • Failed requests are free to retry

Step 9: Optimize for Performance

Sound wave illustration for: Step 9: Optimize for Performance

Optimizing your Python integration ensures your language learning app remains responsive, even when generating high-quality audio at scale. By reducing unnecessary API calls and managing concurrency effectively, you can maintain a smooth user experience while keeping costs predictable.

Leverage Python’s asynchronous capabilities or background threads to synthesize audio without blocking the main UI thread. This approach is particularly useful when users trigger multiple pronunciation checks or reviews in quick succession.

Cache frequent phrases

Store the resulting audio files locally or in a CDN after the first successful request. Since many language learning apps reuse common words, sentences, or phonetic examples, caching eliminates redundant API calls and reduces latency.

Implement a simple key-value store or file-based cache keyed by the input text, voice, and speed parameters. This significantly lowers your character consumption and speeds up repeat interactions for learners.

  • Cache keys should include voice, speed, and language to avoid serving mismatched audio.
  • Invalidate cache entries only if the underlying API changes, which is rare given the static voice presets.

Use background threads for synthesis

Use Python’s threading or asyncio modules to send requests in the background. This allows your app to remain interactive while the TTS engine processes the text, which typically takes a few seconds for short phrases.

This is especially useful for real-time pronunciation drills where users expect immediate feedback, even if the audio generation isn't instantaneous.

  • Limit concurrent requests to stay within the 60 requests per minute rate limit.
  • Handle queueing gracefully if multiple users trigger synthesis simultaneously.

Pre-generate audio for static content

For fixed curriculum content like vocabulary lists or standard dialogues, generate and store the audio files in advance during a build step. This removes runtime dependency on the API for static assets.

This strategy is ideal for offline-first apps or scenarios where network connectivity might be unreliable for language learners on the go.

  • Pre-generate audio for all static lessons during deployment.
  • Store audio files in a format like MP3 or WAV for broad compatibility.

Step 10: Test Your Integration

Sound wave illustration for: Step 10: Test Your Integration

Before integrating the API into your language learning app, verify the synthesis quality using your free trial credit. This $0.50 balance allows approximately 50,000 characters of text generation, valid for seven days. Use this period to confirm that the audio output meets your educational standards without incurring costs.

Test the clarity of pronunciation across different voices and languages. Ensure the synthetic speech remains intelligible for learners at various proficiency levels.

Use free trial credit first

Sign up via Google on the /get-api-key/ page to receive immediate trial credit. This allows you to test the API without entering payment details. Monitor your character usage closely, as the free balance expires after seven days.

Use the provided curl example or Python script to generate short phrases. Verify that the API key is correctly formatted in the Authorization header.

  • Receive $0.50 credit upon Google sign-in
  • Valid for 7 days
  • No payment method required initially

Verify audio quality and clarity

Listen to generated audio for natural intonation and clear articulation. Check that the watermark is inaudible but present. Ensure the audio format (mp3, wav, opus, flac, pcm) suits your app’s requirements.

Test edge cases like punctuation and special characters to ensure they do not disrupt the speech flow. Verify that the speed parameter (0.25–4.0) adjusts the playback correctly for different learning scenarios.

  • Check intonation and articulation
  • Verify audio format compatibility
  • Test punctuation handling

Test multiple voices and languages

Experiment with all 8 voices (aria, nova, luna, sage, felix, milo, atlas, orion) and 23 supported languages. Confirm that the language parameter correctly overrides script-based guessing for non-English Latin text.

Ensure that voice consistency is maintained across different requests. Verify that the API correctly handles requests in languages like Arabic, Chinese, or Swahili if your app supports them.

  • Test all 8 voices
  • Verify 23 language support
  • Check language parameter override

Step 11: Deploy to Production

Sound wave illustration for: Step 11: Deploy to Production

Moving from testing to live usage requires funding your account with USDT on the TRON network. Unlike traditional payment methods, there are no subscriptions or invoices; you simply transfer the minimum $5 amount to receive automatic credit within minutes. This balance does not expire, allowing you to pay only for what your language learning app actually consumes.

Top up your USDT balance

Add funds directly via TRC-20 transfers. Once confirmed, your available characters increase immediately, ready for production traffic without manual approval.

Monitor usage and costs

Track your consumption through the dashboard, which displays character counts and remaining balance. Since pricing is $0.01 per 1,000 characters, you can easily calculate costs based on your app's user volume and text length.

Set up alerts for low balance

While we do not offer automatic credit card charging, you can monitor your dashboard to ensure your app never stops mid-sentence due to insufficient funds. Regular checks prevent unexpected service interruptions during peak learning hours.

Step 12: Maintain Your Code

Sound wave illustration for: Step 12: Maintain Your Code

Maintaining your integration ensures long-term stability for your language learning app. Regular updates and key rotation prevent sudden service interruptions without requiring major code rewrites.

Rotate your API key periodically or immediately if a breach is suspected. This action invalidates the old key instantly, ensuring no unauthorized usage continues.

Review voice selections as your curriculum evolves. While the eight presets remain constant, optimizing which voice matches which language level keeps audio engaging for students.

Keep SDK library updated

The official OpenAI Python library receives updates that may improve error handling or add minor features. Syncing your library version ensures compatibility with the API.

You do not need a proprietary SDK. Standard HTTP libraries like requests remain stable, but checking for library updates quarterly helps avoid deprecated methods.

  • Check pip list for outdated packages monthly.
  • Test after updating the OpenAI SDK to ensure compatibility.

Rotate API keys if compromised

Navigate to the /get-api-key/ page to issue a new key. The old key stops working immediately, so update your environment variables promptly.

This process is simple and requires no downtime if you manage keys via environment variables rather than hardcoding them in your source files.

  • Issue a new key from the dashboard.
  • Update your app's environment variables.
  • Discard the old key securely.

Update voice selections as needed

As you expand your language offerings, map specific voices to learner proficiency levels. For example, use 'sage' for instructional content and 'nova' for lively exercises.

The voice list is static, but your application logic can change which voice is selected based on the user's current lesson type.

  • Map 'sage' to instructional modules.
  • Use 'nova' for interactive quizzes.
  • Test new voice combinations with the free trial credit.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. This extensive catalog allows indie developers to build apps for niche linguistic markets without needing multiple providers.

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. MDN: Web Speech API
  3. OpenAI API reference: create speech
  4. LibriTTS-R paper (arXiv 2305.18802)
  5. LibriTTS-R corpus (OpenSLR 141)
  6. Tether (USDT)
  7. curl documentation
  8. openai-python on GitHub
  9. W3C WAI: making audio and video accessible
  10. Node.js documentation
  11. IETF RFC 7845: Ogg Opus
  12. Creative Commons Attribution 4.0

More on this site