How to Integrate Our TTS API into WordPress Sites?

By ScribbleVoice editorial team · Updated 2026-11-18

This guide shows indie developers how to add reliable text-to-speech to WordPress without complex infrastructure. You will learn to generate audio files via our API and embed players directly into your posts. We cover everything from obtaining your API key to handling character limits and optimizing performance for your readers.

Whether you are building a custom plugin or using existing hooks, this walkthrough provides concrete steps for integration. You will see how to send text to our endpoint, manage USDT top-ups, and debug common issues. By the end, you will have a working solution that improves accessibility and keeps visitors engaged with your content.

How to Integrate Our TTS API into WordPress Sites?

Frequently asked questions

How do I add TTS to a specific post?

Send a POST request to https://api.play67bd.com/v1/audio/speech with your text and API key. Receive an audio file (mp3, wav, opus, flac, or pcm) and embed it directly in your post content using a standard HTML audio tag.

Can I generate audio for all posts automatically?

Yes. Write a script or plugin that iterates through your posts, sends each text to the API, and saves the returned audio file. Since requests are processed sequentially, plan for queue times during bulk generation.

Does the API work with Gutenberg blocks?

Absolutely. Create a custom Gutenberg block that triggers the API call via JavaScript or server-side PHP. Store the resulting audio URL in the post meta and render it using the HTML5 audio element within the block.

How do I cache generated audio files?

Store the returned audio file in your WordPress uploads directory or a CDN. Map the audio URL to the post ID. On subsequent loads, serve the cached file instead of making another API request, saving characters and cost.

What is the best audio format for web?

MP3 offers a good balance of compatibility and file size for web embedding. Opus is also excellent for modern browsers, providing smaller file sizes. We support MP3, WAV, Opus, FLAC, and PCM. Choose based on your audience's browser support needs while keeping file sizes manageable. Note that we do not offer streaming or real-time partial audio, so select the format that best fits your static audio file requirements.

Can I use my own custom voice?

No. We do not offer custom voice cloning or uploading your own voice. You must choose from our eight preset voices (Aria, Nova, Luna, Sage, Felix, Milo, Atlas, Orion) which cover various tones and styles.

How do I handle large blog posts?

Split your text into parts of up to 4096 characters. Send each part as a separate request to the API, then join the resulting audio files. This ensures no single request exceeds the character limit.

Does this work with caching plugins?

Yes, if you implement proper cache-busting or invalidate the cache when new audio is generated. Since audio files are static once created, standard WordPress caching plugins will serve them efficiently after the initial generation.

Can I embed audio in RSS feeds?

Yes. Generate the audio file via the API, upload it to your media library, and add the audio URL to the RSS enclosure tag. This allows podcast clients and feed readers to deliver the audio to subscribers.

How do I track usage costs in WordPress?

Monitor your balance and character usage directly from the /get-api-key/ dashboard. Each request consumes characters based on input length. Failed requests are free, so only successful generations incur the $0.01 per 1,000 characters cost.

Is the API key secure in PHP?

Store your API key in wp-config.php or a custom options table, not in client-side JavaScript. Use it server-side to make the POST request to https://api.play67bd.com/v1/audio/speech, keeping the key hidden from end users.

Can I generate audio on-demand?

Yes. Trigger the API call when a user requests audio or when a post is published. The API returns the audio file in the response, allowing you to deliver it immediately or save it for later use.

How do I handle errors gracefully?

Check the HTTP status code from the API. If synthesis fails, the charge is returned in full. Implement retry logic with exponential backoff for rate limits (60 requests/minute) and display a user-friendly message if audio fails.

Does the API support multiple languages?

Yes, we support 23 languages, including English, Spanish, French, German, Chinese, Japanese, Arabic, and others. Any voice can speak any supported language. You can specify the language via the 'language' parameter or let the API guess it from the script. However, we recommend explicitly setting the language for non-English Latin-script text to ensure accurate synthesis.

Why Add TTS to Your WordPress Site

Sound wave illustration for: Why Add TTS to Your WordPress Site

Adding text-to-speech to your WordPress site transforms static posts into accessible audio content. This small integration helps readers who prefer listening over reading, ensuring your content reaches a wider audience without requiring complex infrastructure.

By offering an audio alternative, you respect different learning styles and usage contexts, making your blog more inclusive and user-friendly for everyone.

Improve accessibility for readers

Many users prefer audio consumption during commutes or while multitasking. Providing an audio version of your posts allows them to engage with your content hands-free, improving the overall accessibility of your site without demanding extra effort from your readers.

It also supports readers with visual impairments or dyslexia, giving them equal access to your written work.

  • Hands-free listening for busy readers
  • Supports visual and learning disabilities
  • No extra plugins required for basic functionality (requires custom code or a plugin you create)

Increase time on site

When visitors can listen to your content, they are more likely to stay engaged. Audio complements reading, encouraging users to explore more posts while the audio plays in the background, naturally extending their session duration.

This passive engagement can lead to higher return visits, as listeners often discover new topics while consuming previous content.

  • Encourages deeper content exploration
  • Supports passive consumption habits
  • Reduces bounce rates for long-form articles

Expand audience reach

Not everyone reads at the same speed or prefers text. By offering audio, you capture audiences who consume media on mobile devices, during workouts, or in noisy environments where reading isn’t practical. This flexibility ensures your message is heard, not just read.

It also allows you to repurpose existing written content into audio formats without hiring voice actors, saving time and resources.

  • Captures mobile and on-the-go listeners
  • Repurposes existing written content easily
  • No need for external voice actors

Step 1: Get Your API Key

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

Before you can turn your WordPress posts into audio, you need a valid API key. This key authenticates your requests to our cloud engine and tracks your usage for billing. Without it, your plugin cannot generate any speech files.

Sign up on our site

Navigate to the /get-api-key/ page on play67bd.com. You can create an account quickly using Google or by entering your email and password. This account is specific to this storefront and gives you immediate access to the dashboard where your credentials live.

  • Sign up via Google or email/password
  • Account is specific to play67bd.com

Copy your secret key

On the dashboard, you will see your active API key starting with tts-.... Copy this string exactly. This is the only credential you need to include in your WordPress plugin or custom code to authorize requests to the API endpoint.

  • Key starts with tts-...
  • One active key per account

Store it securely

Treat your API key like a password. Avoid hardcoding it directly into your plugin’s public JavaScript files, where it could be scraped by third parties. Instead, store it in your WordPress wp-config.php file or use the WordPress Options API to keep it out of version control.

  • Avoid hardcoding in public JS
  • Use wp-config.php or Options API
Step 1: Get Your API Key

Step 2: Create a Plugin or Use Hooks

Sound wave illustration for: Step 2: Create a Plugin or Use Hooks

Adding TTS to WordPress doesn’t require complex infrastructure. You can build a lightweight plugin or use existing hooks to inject audio into your content seamlessly. This approach keeps your site fast and your code clean.

Write a simple PHP plugin

Create a basic plugin file in your wp-content/plugins/ directory. Define the logic to fetch text from posts and call the TTS API. Keep dependencies minimal to ensure compatibility with your existing theme.

  • Create a folder named scribblevoice-tts
  • Add a plugin.php with standard headers
  • Enqueue assets only on post pages

Use WordPress hooks for post rendering

Hook into the_content to automatically append audio players to your posts. This ensures every article gets an accessible audio version without editing each post manually. Use apply_filters to let other plugins modify the output if needed.

Store key in wp-config.php

Keep your API key secure by storing it in wp-config.php as a constant. Avoid hardcoding it in your plugin files, which might be committed to version control. This prevents accidental exposure of your secret key.

  • Add define('SV_API_KEY', 'tts-your-key-here'); (example constant name)
  • Use getenv for environment variable support
  • Restrict file permissions to 640 or 600

Step 3: Send Text to the API

Sound wave illustration for: Step 3: Send Text to the API

Sending text to the API is the core of your WordPress integration. You can use WordPress’s built-in HTTP API or raw cURL to make requests. This step converts your post content into a format the API understands.

The API expects a POST request to /v1/audio/speech. You must include your secret key in the Authorization header and specify the model, voice, and input text in the JSON body.

Use cURL or WordPress HTTP API

WordPress provides the wp_remote_post function, which is the preferred way to make HTTP requests from within your plugin. It handles authentication and error responses cleanly. Alternatively, you can use standard cURL for more control.

Both methods allow you to pass the JSON payload containing your text, selected voice, and desired audio format. Ensure your plugin code sanitizes the post content before sending it to avoid encoding issues.

  • Use wp_remote_post for simplicity
  • Ensure JSON encoding is correct
  • Handle response codes properly

Send POST request to /v1/audio/speech

Direct your request to https://api.play67bd.com/v1/audio/speech. Include the Authorization: Bearer tts-... header with your unique key. The body must be a JSON object with model, voice, input, and response_format.

The API processes requests sequentially. For long texts, split the content into chunks of 4096 characters. The API returns the audio file directly in the response body, which you can then save.

  • Endpoint: POST /v1/audio/speech
  • Header: Authorization: Bearer your-key
  • Body: JSON with model, voice, input

Pass text content from post

Extract the post title and content using WordPress functions like get_the_title() and get_the_content(). Combine them into a single string for the input field. Remember that spaces and punctuation count toward the 4096-character limit.

If the text exceeds the limit, split it into parts. Send each part as a separate request and concatenate the resulting audio files. This ensures no content is lost during generation.

  • Use get_the_content() for text
  • Split text if >4096 chars
  • Count spaces and punctuation

Step 4: Handle the Response

Sound wave illustration for: Step 4: Handle the Response

Once the API returns the binary audio stream, your plugin needs to capture that data correctly. Do not attempt to parse it as JSON; the response body is the raw audio file itself, formatted according to your response_format choice (mp3, wav, etc.).

Ensure your HTTP client handles binary streams without corruption. If the request fails, the API returns an error JSON, so always check the HTTP status code before processing the body.

Receive audio file in response

The API endpoint returns the audio file directly in the response body. Use WordPress’s wp_remote_post with stream set to true to handle the binary data efficiently. This prevents memory issues when processing large audio files from longer texts.

Save file to media library

Store the received binary data in WordPress’s media library using wp_insert_attachment. This ensures the audio file is managed alongside your other assets and accessible via WordPress’s native URL structures. Name the file using the post ID to avoid collisions.

  • Use wp_upload_bits() to write the file safely.
  • Attach the file to the current post for proper ownership.

Generate audio URL for embedding

Retrieve the attachment URL using wp_get_attachment_url(). This gives you a direct link to the hosted audio file, which you can then insert into an HTML5 <audio> tag. This URL remains valid as long as the media library entry exists.

Step 5: Embed Audio Player

Sound wave illustration for: Step 5: Embed Audio Player

Once your API returns the audio file, embedding it is straightforward. Using the native HTML5 <audio> tag ensures broad compatibility across all modern browsers without requiring external JavaScript libraries or heavy plugins. This keeps your WordPress site lightweight and fast.

You can place the audio player directly within the post content or in the sidebar. This gives readers immediate access to the synthesized voice, enhancing accessibility for those who prefer listening over reading, or for on-the-go consumption of your blog posts.

Use HTML5 audio tag

The HTML5 <audio> element is the standard for embedding sound. It provides a clean, browser-native player that handles play, pause, and volume controls automatically. Since the API returns a standard audio file (mp3, wav, etc.), the tag works immediately without extra configuration.

Simply insert the <audio> tag with the src attribute pointing to the URL of your generated audio file. You can also add attributes like controls to display the player interface and autoplay if you want the audio to start automatically when the post loads.

  • Use the controls attribute to show play/pause buttons.
  • Set preload="none" to save bandwidth if audio is not immediately needed.
  • Supports standard formats like mp3, wav, opus, flac, and pcm returned by the API.

Add player to post template

To automate this process, modify your theme’s single post template (usually single.php or a block template). After the post content is rendered, you can hook into the theme to automatically inject the audio player if an audio file exists for that post.

This approach ensures that every new post with generated audio gets a consistent player layout. You can use WordPress hooks like the_content to append the audio HTML after the text, ensuring it appears naturally in the reading flow without manual editing for each article.

For static sites or less frequent updates, you might generate the audio URL during the build process and hardcode it into the template. This reduces server load and ensures the player is always available, even if the API is temporarily slow.

  • Hook into the_content to append audio automatically.
  • Check if an audio file exists before rendering the player.
  • Consider pre-generating URLs for static site generators.

Style player to match theme

The default HTML5 audio player varies by browser and operating system. To maintain a professional look, you can use CSS to style the player container or replace it with a custom UI using JavaScript. This ensures the audio controls blend seamlessly with your site’s color scheme and typography.

For a minimal approach, wrap the <audio> tag in a div with custom padding and borders. This makes the player stand out as a distinct section, encouraging users to engage with the audio content. Consistent styling helps reinforce your brand identity across all posts.

If your theme supports custom blocks, you can create a reusable Gutenberg block for audio. This allows you to drag and drop the player into any post or page, giving you full control over its position and appearance without editing code for each article.

  • Use CSS to adjust padding, borders, and background colors.
  • Create a custom Gutenberg block for easy insertion.
  • Ensure the player is responsive on mobile devices.
Step 5: Embed Audio Player

Step 6: Optimize for Performance

Sound wave illustration for: Step 6: Optimize for Performance

WordPress sites can generate audio on-the-fly, but this adds latency for every visitor. To keep your site snappy, you should cache the resulting audio files rather than regenerating them for each request.

Cache generated audio files

Store the generated MP3 or WAV files in your WordPress media library. Subsequent visits serve the static file, reducing API calls and server load significantly.

  • Save audio as attachments in the Media Library.
  • Use a caching plugin to serve static files quickly.
  • Ensure cache keys are unique per post ID.

Limit generation to specific posts

Not every article needs audio. Configure your plugin to only trigger synthesis for posts where you explicitly enable the TTS feature, conserving your character quota and API rate limits.

  • Use a custom meta box to toggle audio generation.
  • Skip generation for short excerpts or pages.
  • Reserve API calls for long-form content.

Use asynchronous generation if needed

For very long texts, synthesis might take several seconds. Use WordPress async cron jobs to generate audio in the background when the post is saved, ensuring the user gets an instant load time.

  • Trigger synthesis via wp_cron after saving.
  • Notify the user when audio is ready.
  • Handle failures gracefully with retry logic.

Step 7: Manage Costs

Sound wave illustration for: Step 7: Manage Costs

Managing your TTS budget is straightforward because costs are directly tied to character count. Each request processes up to 4,096 characters, and you are charged $10 per million characters, regardless of audio format or voice selected. Failed requests are free, so you only pay for successful synthesis. This transparent model helps you predict expenses accurately without hidden fees or minimum spends.

Understanding your usage patterns allows you to optimize content length. Since spaces and punctuation count as characters, breaking long articles into smaller chunks can help you stay within rate limits while keeping costs predictable. You can monitor your balance and character usage directly from your dashboard.

Monitor character usage

Access your dashboard to view real-time usage statistics. The interface displays your current balance, characters consumed, and remaining trial credit. This data helps you track how much content you have converted to audio and ensures you stay within your budget.

You can also calculate costs manually. For example, a 10,000-character post costs approximately $0.10. This clarity helps indie developers and bloggers estimate costs before publishing.

  • View real-time balance and character consumption
  • Track usage per request (voice and language are not tracked individually in billing)
  • Identify high-character posts for optimization

Set budget alerts

While the API does not offer built-in alert emails, you can monitor your dashboard regularly. Set a reminder to check your balance weekly, especially if you publish frequently. This proactive approach prevents unexpected service interruptions due to insufficient funds.

Since accounts start with a $0.50 trial (50,000 characters), you can test your integration without immediate cost. Once the trial expires, ensure your balance is sufficient before scaling up your audio content.

  • Check dashboard weekly
  • Monitor trial expiration
  • Track character consumption trends

Top up via USDT when needed

When your balance is low, top up using USDT on the TRON network (TRC-20). The minimum top-up amount is $5, and credits are credited automatically within minutes of transfer. This method is efficient and avoids the hassle of credit cards or invoices.

There are no subscriptions or monthly plans, so you only pay for what you use. Your balance does not expire, allowing you to top up whenever convenient. This flexibility is ideal for developers with variable publishing schedules.

Simply send TRC-20 USDT to your provided wallet address. No VAT or additional fees apply, keeping your costs transparent and predictable.

  • Minimum top-up: $5
  • Supported network: TRON (TRC-20)
  • Credits credited automatically within minutes
  • No subscriptions or monthly plans
  • Balance never expires

Step 8: Test and Debug

Sound wave illustration for: Step 8: Test and Debug

Testing ensures your WordPress integration handles both quick phrases and longer articles correctly. Start by verifying that short inputs return audio instantly, while longer texts are split and joined without errors. This confirms your character limit logic and queue handling work as expected under load.

Debugging also involves monitoring your API key usage and error rates. Verify that failed requests do not incur charges and that your caching layer prevents duplicate generation for identical content. This keeps your site fast and your costs predictable.

Test with short and long texts

Send a 50-character string to verify immediate response times. Then, submit a 4,000-character text to ensure the 4,096-character limit is respected and that the audio files are correctly concatenated. Check that the final audio duration aligns with the expected real-time speed of roughly 25 characters per second.

  • Verify short phrases return within a few seconds.
  • Ensure long texts are split into valid chunks.
  • Confirm audio files play seamlessly when joined.

Check error responses

Monitor HTTP status codes and JSON error messages from the API. If a request fails, ensure the system returns the correct error code without charging your balance. Test edge cases like invalid voice IDs or unsupported formats to confirm your plugin handles these gracefully without breaking the page layout.

Note that requests are processed sequentially, so under heavy load, you might see temporary delays. Ensure your code handles these timeouts gracefully.

  • Validate HTTP 400/500 error handling.
  • Confirm failed requests are free.
  • Check timeout handling for queued requests.

Verify audio quality and speed

Listen to the generated audio to ensure the voice matches your selected preset and language. Check that the speed parameter (0.25–4.0) adjusts the playback rate correctly. For non-English Latin text, ensure the language field is set to avoid incorrect English voice selection.

Verify that the audio file format (mp3, wav, etc.) is compatible with your WordPress theme’s audio player. Test playback on mobile devices to ensure consistent performance.

  • Check voice clarity and language accuracy.
  • Test speed adjustments (0.25–4.0x).
  • Verify format compatibility with audio players.

Common WordPress Integration Issues

Sound wave illustration for: Common WordPress Integration Issues

Integration hiccups are normal. This section covers the three most frequent blockers WordPress developers face when connecting the TTS API to their themes or plugins.

We focus on practical fixes for key validation, cross-origin audio playback, and text length constraints that often trip up new implementations.

API key not found errors

Ensure your secret key is correctly retrieved from wp-config.php or your plugin settings. A missing or malformed key returns a 401 error immediately.

Verify the key starts with tts- and contains no extra whitespace. Regenerate the key in your dashboard if you suspect it was compromised.

  • Check for trailing spaces in the key string.
  • Confirm the key is active and not expired.
  • Use the exact key from the /get-api-key/ page.

CORS issues with audio players

Browsers block cross-origin audio requests if the API domain isn't whitelisted. Ensure your WordPress site allows loading assets from api.play67bd.com.

Use the HTML5 <audio> tag with a direct URL to the cached file, not the raw API endpoint, to avoid CORS blocks during playback.

  • Add api.play67bd.com to your CSP if strict.
  • Cache audio locally to bypass CORS on load.
  • Use absolute URLs for the audio source.

Character limit exceeded

The API accepts a maximum of 4096 characters per request. If your post exceeds this, split the text into chunks before sending.

Concatenate the resulting audio files or play them sequentially. Ensure your plugin handles the character count accurately, including spaces and punctuation.

  • Count characters including spaces and punctuation.
  • Split text at sentence boundaries where possible.
  • Return an error if the limit is exceeded.
Common WordPress Integration Issues

Advanced Tips for Developers

Sound wave illustration for: Advanced Tips for Developers

For static site generators, pre-generating audio files during the build process ensures instant playback without runtime API calls. This approach eliminates latency and avoids hitting rate limits during traffic spikes, providing a consistent experience for your readers.

Pre-generate audio for static sites

Integrate the TTS API into your build script to convert all blog posts into audio files before deployment. Store these files in your CDN or media library, allowing users to listen immediately without waiting for real-time synthesis.

  • Run synthesis during CI/CD pipeline
  • Store results in public storage
  • Link audio to post metadata

Use background workers for long texts

Since the API processes requests sequentially, long articles may queue behind other users. Use a background worker to split the text into 4096-character chunks, send them sequentially, and join the resulting audio files asynchronously.

  • Split text into 4096 char parts
  • Queue requests to avoid limits
  • Join audio segments server-side

Implement retry logic for failures

Network hiccups or temporary API overload can cause synthesis failures. Implement exponential backoff retry logic in your plugin to automatically re-attempt failed requests, ensuring that your audio player eventually delivers content without user intervention.

  • Use exponential backoff
  • Handle HTTP 503 errors
  • Log failed attempts for debugging

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Publish your latest coding discoveries and personal reflections using a reliable blogging platform to grow your independent audience effectively.

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. Creative Commons Attribution 4.0
  3. IETF RFC 7845: Ogg Opus
  4. OpenAI API reference: create speech
  5. Python documentation
  6. MDN: Web Speech API
  7. curl documentation
  8. TRON developer hub: TRC-20
  9. W3C WAI: making audio and video accessible
  10. Tether (USDT)
  11. LibriVox public-domain audiobooks
  12. FFmpeg documentation

More on this site