How to Generate Podcast Audio with Python TTS API?

By Podcast TTS Lab editorial team · Updated 2026-11-19

This guide walks podcast creators through generating narration from scripts using Python. You will learn to send text to the Podcast TTS Lab API and receive audio files with minimal code. We focus on practical, step-by-step implementation so you can integrate synthetic voices into your production workflow without unnecessary complexity.

By the end, you will know how to configure the client, handle large scripts, and manage errors effectively. This page is designed for developers who need a reliable, character-based API for podcast automation, providing concrete examples and clear instructions for every stage of the process.

How to Generate Podcast Audio with Python TTS API?

Frequently asked questions

Do I need to install any specific libraries?

You can use the official OpenAI Python SDK by changing the base URL to https://api.wtc88.cc/v1. Alternatively, standard HTTP libraries like requests work perfectly. No proprietary SDK is required, allowing you to integrate the TTS API into your existing Python environment with minimal setup and dependency overhead.

Can I use the API with Python 2?

The API uses standard HTTP JSON requests, so any Python version supporting basic HTTP libraries can interact with it. While the official OpenAI SDK requires Python 3.7+, you can use standard HTTP libraries with older Python versions. Ensure your environment handles JSON serialization and binary audio response decoding correctly.

How do I handle encoding issues?

The API returns audio in binary format. Ensure your Python script handles binary responses correctly by reading the response content as bytes. Specify the desired response_format (mp3, wav, opus, flac, or pcm) in your request. This avoids character encoding issues since audio data is not text-based.

Is the API synchronous or asynchronous?

The API is synchronous. You send a POST request and wait for the audio file response. Requests are processed sequentially, so under load, your request may wait in a queue. You must handle the wait time in your code before proceeding to the next step.

Can I generate audio in the background?

Since the API is synchronous, you must manage background generation yourself. Use Python threading or async libraries to send requests while your main thread continues. This allows you to process multiple scripts concurrently without blocking your application, though each request still waits for the final audio file.

How do I play audio directly in Python?

Save the binary response to a file or use a library like pygame or sounddevice to play it in memory. The API supports formats like mp3, wav, opus, flac, and pcm. Choose a format compatible with your playback library to ensure seamless file creation.

What is the latency of the API?

Latency depends on text length and server load. Long texts generate at roughly real-time speed (25 characters per second). Short phrases take a few seconds. Requests are processed sequentially, so high demand may increase wait times. Plan your workflow to account for these variable processing durations.

Can I use the API with Jupyter Notebooks?

Yes, the API works well with Jupyter Notebooks. Use the requests library or OpenAI SDK to send POST requests. Since the API is synchronous, long texts may block the notebook interface. Consider running requests in separate threads or cells to keep the interface responsive during generation.

How do I deploy this to a server?

Deploy your Python script as usual. Ensure your server has internet access to reach https://api.wtc88.cc/v1. Store your API key securely using environment variables. The API handles audio generation, so your server only needs to manage request sending, response receiving, and file storage or playback.

Is Docker support available?

No official SDK or mobile SDK is provided. However, since the API uses standard HTTP requests, you can easily containerize your Python application. Include the necessary dependencies in your Dockerfile, and your container will interact with the API just like any other Python environment.

Can I use this with AWS Lambda?

Yes, you can use the API with AWS Lambda. Package your Python code and dependencies into a Lambda function. Ensure the function has internet access to call https://api.wtc88.cc/v1. Be mindful of Lambda’s execution time limits, as long text generation may exceed the default timeout duration due to sequential processing.

How do I handle network timeouts?

Implement timeout settings in your HTTP library to handle network issues. Since requests are processed sequentially, high load may increase latency. Set appropriate timeout values to prevent your script from hanging indefinitely. Retry logic can help manage transient network errors during audio generation.

What is the best practice for error handling?

Check the HTTP status code and response body for errors. Failed requests are free, so ensure you handle billing correctly. Implement retry logic for transient errors like network timeouts. Validate your input text length (max 4096 characters) to avoid request failures before sending the audio synthesis request.

Can I use this with FastAPI?

Yes, the API integrates well with FastAPI. Use the requests library or OpenAI SDK within your FastAPI endpoints to generate audio. Since the API is synchronous, consider using async HTTP clients or background tasks to avoid blocking the FastAPI server during audio generation requests.

Prerequisites

Sound wave illustration for: Prerequisites

To generate podcast audio using Python, you need a working Python environment (3.7 or higher) and a valid API key from the Podcast TTS Lab dashboard. These are the only two components required before writing your first script.

Python 3.7+ installed

Ensure your development environment runs Python 3.7 or later. This version supports the asynchronous features and type hinting used in modern API client libraries.

API key from the dashboard

Navigate to /get-api-key/ on the Podcast TTS Lab site. Sign in with Google or your email to retrieve your unique key. This key authenticates all requests sent to the endpoint.

  • Keys are issued per account and site.
  • A new key invalidates the old one immediately.

OpenAI SDK library

Install the official OpenAI Python SDK. Although this is a standalone API, it uses the same request shape as the OpenAI speech endpoint, allowing you to reuse familiar code structures.

  • Install via: pip install openai

Installing Dependencies

Sound wave illustration for: Installing Dependencies

Install the official OpenAI Python library, which handles the underlying HTTP requests. This version supports the type hinting used in modern API client libraries. Ensure you are using a compatible Python environment (3.7+) before proceeding with the installation command.

pip install openai

Run the standard package manager command to fetch the library. This single step adds all necessary dependencies for making REST calls to the TTS endpoint. No additional third-party tools are required for basic integration.

Import necessary modules

Import the OpenAI class from the openai package. You will also need the Path module from the pathlib library to handle file system operations for saving the generated audio files securely.

  • from openai import OpenAI
  • from pathlib import Path

Configure environment variables

Store your API key in an environment variable named OPENAI_API_KEY. This prevents hardcoding sensitive credentials in your source code. The dashboard on /get-api-key/ provides your unique key for this purpose.

Configuring the Client

Sound wave illustration for: Configuring the Client

Configuring the Python client correctly ensures your scripts communicate with the right endpoint. You must set your API key and override the default base URL so the SDK points to https://api.wtc88.cc/v1 instead of OpenAI's servers. This setup allows you to use the standard OpenAI SDK while accessing Podcast TTS Lab’s specific voices and pricing.

Once configured, verify the connection by fetching the list of available voices. This confirms your authentication and base URL are accurate before you start generating audio, preventing wasted credits from misconfigured calls.

Set API key

Retrieve your unique API key from the /get-api-key/ dashboard. Store it in an environment variable or pass it directly to the SDK. The key starts with tts- and authenticates all requests. Only one active key exists per account; issuing a new one instantly invalidates the previous one.

  • Use Authorization: Bearer tts-... header
  • Keys are issued per site account
  • Revoke old keys instantly

Override base_url

By default, the OpenAI SDK points to OpenAI’s infrastructure. Override the base_url to https://api.wtc88.cc/v1 to route requests to our TTS engine. This change is transparent to the SDK; you continue using standard methods like Audio.speech() but access our 8 voice presets and character-based pricing.

  • Base URL: https://api.wtc88.cc/v1
  • Compatible with official OpenAI SDKs
  • No custom SDK required

Verify connection

Before generating audio, verify that the client connects correctly. A simple request to the /v1/voices endpoint confirms your authentication and base URL configuration are accurate. This prevents wasted credits from misconfigured calls.

Making the First Call

Sound wave illustration for: Making the First Call

Once the client is configured, you construct a JSON payload containing the text, voice selection, and desired output format. The API accepts standard TTS parameters, allowing you to specify the model and language explicitly to ensure accurate synthesis for your podcast script.

Construct JSON payload

Define the input text up to 4096 characters and select one of the eight voice presets. Include the response format (mp3, wav, etc.) and optional speed adjustments to match your podcast's pacing requirements.

  • Ensure text length stays within the 4096 character limit per request.
  • Select a voice that matches the narrative tone of your episode.

Send POST request

Execute a POST request to the speech endpoint using your API key. The service processes the request sequentially, so expect slight delays during high load periods.

Save response to file

The API returns the audio file directly in the response body. Write this binary data to a local file with the appropriate extension for immediate playback or further editing.

  • Verify the file header matches the requested response format.
  • Check the file size to ensure complete transmission.

Choosing the Right Voice

Sound wave illustration for: Choosing the Right Voice

Selecting the appropriate voice is critical for podcast retention. Our API provides eight distinct presets, each designed for specific narrative styles. Whether you need a warm narrator or a neutral news reader, the choice directly impacts listener engagement.

Match your voice to your content’s tone. Use 'aria' for clear storytelling or 'atlas' for straightforward news updates. Each voice is based on licensed recordings, ensuring consistent quality without the need for custom cloning.

Select from 8 presets

The API offers eight voice options: aria, nova, luna, and sage (female); felix, milo, atlas, and orion (male). Each preset has a distinct character, from upbeat to documentary-style deep voices.

Voices are licensed from LibriTTS-R and LibriVox, ensuring legal clarity for commercial use. All voices support all 23 languages, though setting the language field is recommended for non-English Latin text.

  • 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

Match tone to content

Align the voice with your podcast genre. Use 'atlas' for factual reporting or 'orion' for documentary-style deep narration. 'milo' works well for conversational interviews, while 'nova' suits promotional segments.

Avoid mismatching tone; a deep documentary voice may feel odd for a lighthearted comedy podcast. Test combinations to ensure the audio complements your script’s pacing and emotional arc.

  • Use 'atlas' for news
  • Use 'orion' for documentaries
  • Use 'milo' for conversations

Test samples

Generate short samples before committing to a full episode. Use the trial credit to test different voices with your specific script. This helps identify which voice resonates best with your audience.

Check audio quality and tone consistency. Ensure the voice handles your specific vocabulary and pacing correctly. Adjust the speed parameter if the default pace feels too fast or slow for your content.

  • Test with trial credits
  • Check tone consistency
  • Adjust speed if needed

Handling Large Scripts

Sound wave illustration for: Handling Large Scripts

Podcast scripts often exceed the 4096-character limit per request. You must split your input text into smaller chunks before sending them to the API.

Once generated, the individual audio segments need to be joined into a single file for your podcast workflow.

Chunk text logic

Split your script into parts of up to 4096 characters. Each part becomes a separate API call. This ensures every segment stays within the single-request limit.

  • Count characters including spaces and punctuation
  • Preserve paragraph breaks for natural pauses
  • Ensure each chunk is under 4096 chars

Concatenate audio

The API returns distinct audio files for each chunk. Use a library like pydub or subprocess to merge these files sequentially. This creates one continuous narration track.

Manage memory

Large scripts generate multiple audio files. Process chunks sequentially or use generators to avoid loading all audio into RAM at once. This prevents memory exhaustion during long episodes.

Error Handling

Sound wave illustration for: Error Handling

Robust error handling ensures your podcast production pipeline doesn’t halt on transient network issues. By wrapping API calls in try-except blocks, you catch specific exceptions like rate limits or invalid inputs, allowing your script to log the issue and continue processing the next segment.

This approach prevents a single failed synthesis from crashing your entire batch job, keeping your workflow stable even when the API experiences brief load spikes.

Try-except blocks

Always wrap the openai.audio.speech.create() call in a try block. Catch openai.RateLimitError separately to handle the 60 requests per minute limit without wasting characters. Catch generic Exception for unexpected network errors to ensure your script logs the failure and moves to the next chunk of text.

This structure ensures that a temporary service hiccup doesn’t stop your podcast generation process entirely.

  • Catch openai.RateLimitError to respect the 60 req/min limit.
  • Catch openai.APIConnectionError for network issues.
  • Use generic Exception as a fallback for unknown errors.

Retry on failure

Implement exponential backoff for transient errors like RateLimitError or APIConnectionError. Start with a short delay (e.g., 1 second) and increase it with each retry attempt. This prevents your script from hammering the API immediately after it recovers from a brief outage.

Since requests are processed sequentially under load, a short delay often allows the queue to clear, allowing your next request to succeed without waiting too long.

  • Retry up to 3 times on transient errors.
  • Start with a 1-second delay, doubling each time.
  • Do not retry on AuthenticationError or InvalidRequestError.

Log errors

Log every failed request with the input text snippet, error code, and timestamp. This helps you diagnose issues like invalid characters or voice mismatches later. Use Python’s logging module to write errors to a file or console for easy review.

Detailed logs are crucial when debugging why a specific segment of your podcast script failed to generate, especially when processing large files.

  • Log error type, message, and timestamp.
  • Include the first 50 characters of the input text for context.
  • Save logs to a file for post-processing review.
Error Handling

Optimizing Workflow

Sound wave illustration for: Optimizing Workflow

Streamline your podcast production pipeline by caching audio files to avoid re-synthesizing identical narration segments. Since requests are processed sequentially, storing generated MP3s locally reduces latency and minimizes API calls during iterative editing phases.

Cache generated audio

Store hashed text-to-audio mappings in a local directory. This prevents redundant generation for repeated intro/outro segments or recurring episode structures, keeping your character count stable and costs predictable.

Parallel requests

The API processes requests sequentially, so concurrent submissions may queue. Use Python’s concurrent.futures or asyncio to manage multiple voices or language variants efficiently. Monitor queue depth to avoid exceeding the 60 requests per minute limit per key.

Monitor usage

Track your character consumption and API usage to prevent unexpected charges. Regularly check the dashboard to see remaining balance and character counts, ensuring you have sufficient funds for TRC-20 top-ups before production runs.

Testing in Production

Sound wave illustration for: Testing in Production

Testing ensures your generated audio meets podcast standards before going live. Start by using your free trial credits to generate short clips without risking your main balance. This allows you to verify voice selection and speed settings in a real-world context.

Once the audio is generated, listen closely for clarity and pacing. Ensure the synthetic speech flows naturally for your specific content type, whether it’s narrative storytelling or conversational interviews. Adjust the speed parameter if the delivery feels too fast or sluggish.

Use trial credits first

The $0.50 trial credit provides about 50,000 characters of generation. Use this budget to test multiple voices and languages without incurring costs. This is the safest way to validate your workflow before scaling to larger scripts.

Ensure your API key is correctly configured in your Python environment. Verify that the base URL points to https://api.wtc88.cc/v1 to avoid connection errors during testing.

  • Start with the free $0.50 trial credit
  • Test voices before committing main balance
  • Verify API key and base URL configuration

Check audio quality

Listen to the output for natural intonation and clear articulation. Since voices are based on licensed recordings, the audio is synthetic speech. Check that the speed parameter (0.25–4.0) matches your desired podcast pace.

Remember that requests are processed sequentially, so long texts may take time. Use short phrases first to ensure the synthesis engine is responding correctly before processing full episodes.

  • Listen for natural intonation
  • Verify speed parameter suitability
  • Check articulation clarity

Validate formats

Ensure the generated audio file matches your required format (mp3, wav, opus, flac, or pcm). Incorrect format selection can cause playback issues in your podcast hosting platform. Always save the response binary data correctly to your local drive.

Verify that the audio file is not corrupted and plays smoothly. Test the file in your preferred podcast editor or player to confirm compatibility with your production pipeline.

  • Select correct output format (mp3, wav, etc.)
  • Verify file integrity
  • Test in podcast editor

Common Pitfalls

Sound wave illustration for: Common Pitfalls

Even a simple script can hit limits quickly if you don't account for the queue. Requests are processed sequentially, so under load, delays accumulate. Ignoring the 60 requests per minute cap leads to wasted time waiting for synthesis to complete rather than your code failing.

Character counting errors also cause unexpected costs or truncations. Spaces and punctuation count toward the 4096-character limit per request. If your script miscalculates, you might split a sentence awkwardly or exceed the budget without realizing it until the invoice arrives.

Ignoring rate limits

The API enforces a hard limit of 60 requests per minute per key. If you send more, subsequent requests may queue or fail. New accounts start with 10 requests per minute until the first top-up. Plan your batch sizes accordingly to avoid blocking your pipeline.

Since requests are processed one after another, long texts take time. A 10,000-character script might take minutes to generate. Do not assume instant results. Implement exponential backoff if you use parallel threads, but remember the queue is shared.

  • New accounts: 10 req/min; standard: 60 req/min
  • Requests queue sequentially; no parallel processing guarantee
  • Exceeding limits causes temporary failures, not data loss

Mismatched character counts

The pricing is $0.01 per 1,000 characters, and spaces count. If your script strips punctuation before counting, you might underestimate costs. Always count the exact string sent to the API. A 4,095-character text fits; 4,096 fits; 4,097 fails.

Splitting long scripts into chunks requires care. Each chunk is a separate request with its own latency. If you split mid-sentence, the audio will have unnatural pauses. Use natural break points like periods or commas to ensure smooth playback.

  • Space and punctuation count as characters
  • Max 4096 characters per single request
  • Split at natural sentence breaks to avoid awkward pauses

Wrong base URL

The OpenAI SDK works, but only if you point it to the correct base URL. Use https://api.wtc88.cc/v1. If you leave it as the default OpenAI endpoint, you will get a 404 or authentication error because the voices and models are different here.

Ensure your environment variables are set correctly. A typo in the domain or path breaks the connection. Verify the URL in your configuration before running any tests. It is easy to copy-paste the wrong endpoint from documentation.

  • Base URL: https://api.wtc88.cc/v1
  • Not compatible with default OpenAI base_url
  • Check for typos in domain or path

Debugging Tips

Sound wave illustration for: Debugging Tips

Debugging TTS integrations often hinges on interpreting the API's precise responses and input constraints. Since the service uses standard HTTP conventions, understanding status codes and input formatting is critical for identifying failures quickly.

This section focuses on immediate diagnostic steps to resolve common issues without requiring deep infrastructure changes or external support.

Check response status

Inspect the HTTP status code returned by the POST request. A 200 OK indicates success, while 4xx errors typically signal authentication issues or invalid parameters. 5xx errors suggest temporary server load, which may require a brief retry.

If the response body contains an error object, read the message field for specific details like invalid voice IDs or unsupported formats.

  • 401 Unauthorized: Verify your Authorization: Bearer header matches your API key.
  • 429 Too Many Requests: You have exceeded the 60 requests per minute limit.
  • 503 Service Unavailable: The queue is full; wait a few seconds and retry.

Verify input text

Ensure the input field does not exceed 4096 characters. If your script is longer, the API will reject the request or require chunking. Remember that spaces and punctuation count toward this limit.

Check for special characters or encoding issues that might break the JSON payload. Non-ASCII characters are supported, but ensure they are properly encoded in UTF-8.

  • Character count must be <= 4096 per request.
  • Ensure response_format is one of: mp3, wav, opus, flac, pcm.
  • Validate voice is one of the 8 available presets.

Review logs

Log the request timestamp, character count, and voice used for each call. This helps correlate failed audio files with specific input data.

If audio is silent or distorted, check if the speed parameter is set outside the 0.25–4.0 range, which can cause playback issues in some players.

  • Log request ID and timestamp for billing reconciliation.
  • Log speed and response_format used for each generation.
  • Note any language overrides to ensure correct voice selection.

Next Steps

Sound wave illustration for: Next Steps

Once your scripts generate reliably, you can move beyond manual testing by connecting the API directly to your content management system. This allows your podcast feed to update automatically whenever new episodes are drafted, ensuring your narration stays in sync with your editorial workflow without manual downloads or file transfers.

Integrate with CMS

Use the API key in your backend scripts to fetch audio on demand. By storing the generated audio URLs or files in your media library, you ensure consistent voice branding across all episodes without manual intervention.

  • Store audio files in your media library
  • Link audio to episode metadata
  • Use consistent voice for all episodes

Automate publishing

Set up cron jobs or webhooks to trigger synthesis when you publish a new post. This removes the bottleneck of waiting for human narration, allowing you to release content faster and more frequently.

  • Trigger synthesis on publish
  • Use cron jobs for scheduled tasks
  • Reduce manual workload

Scale production

As your content grows, monitor your character usage and balance. Since pricing is character-based, you can predict costs accurately. Consider batching requests to stay within the 60 requests per minute limit efficiently.

  • Monitor character usage
  • Predict costs accurately
  • Batch requests to stay within limits

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. For longer episodes, split the script into parts and concatenate the generated audio files.

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. Python documentation
  3. Tether (USDT)
  4. ISO 639 language codes
  5. MDN: Web Speech API
  6. W3C WAI: making audio and video accessible
  7. curl documentation
  8. FFmpeg documentation
  9. IETF RFC 7845: Ogg Opus
  10. openai-python on GitHub
  11. LibriVox public-domain audiobooks
  12. openai-node on GitHub

More on this site