Overview
If you’ve ever wanted to add lifelike voice synthesis to a website—think a virtual assistant, a narration tool, or a personalized greeting—you’re in the right place. This guide walks you through building a lightweight voice‑AI web app that pulls speech from ElevenLabs’ API and then serves it from a WordPress site hosted on Bluehost. The result? A production‑ready, cost‑effective, and developer‑friendly stack that’s ready to scale.
Why ElevenLabs?
ElevenLabs’ text‑to‑speech (TTS) engine is a game‑changer for developers who need:
- High‑quality, natural‑sounding voices – dozens of voices in multiple languages, each with expressive prosody.
- Voice cloning – upload a short audio sample and generate speech that sounds like the original speaker.
- Simple, well‑documented API – a REST endpoint that accepts text and returns a WAV/MP3 file in seconds.
For a quick prototype or a production app, ElevenLabs gives you a ready‑made voice engine without the overhead of training your own model. Just sign up via the affiliate link below, grab your API key, and you’re ready to go.
👉 Try ElevenLabs – Get started today and unlock premium voices.
Why WordPress + Bluehost?
WordPress powers roughly 40 % of the web, and it’s a natural fit for a voice‑enabled site:
- Rapid UI building – use themes or Gutenberg blocks to design pages in minutes.
- Plugin ecosystem – add shortcodes, custom post types, or REST endpoints without writing a single line of PHP.
- Community support – countless tutorials and forums mean you’re never alone when something breaks.
Bluehost is the hosting partner that makes that WordPress experience painless:
- One‑click WordPress installs – no command line, no server‑side tinkering.
- Affordable plans – starting at a few dollars a month, with free domain and SSL.
- Optimized performance – SSD storage, CDN, and auto‑scaling for traffic spikes.
👉 Get a Bluehost account – the easiest way to get your WordPress site live.
Step 1 – Sign Up for ElevenLabs
- Click the link above and create an account.
- In the dashboard, find your API key under Account > API.
- Note the key; you’ll need it in the code snippet below.
Step 2 – Create a Simple API Endpoint in WordPress
We’ll expose a tiny REST route that accepts a text payload, forwards it to ElevenLabs, and streams back the audio.
<?php
/**
* Plugin Name: Voice Synth API
* Description: Simple endpoint to synthesize text with ElevenLabs.
* Version: 1.0
* Author: Dev
*/
add_action( 'rest_api_init', function () {
register_rest_route( 'voice/v1', '/synthesize', array(
'methods' => 'POST',
'callback' => 'voice_synthesize_callback',
'permission_callback' => '__return_true',
) );
} );
function voice_synthesize_callback( WP_REST_Request $request ) {
$text = sanitize_text_field( $request->get_param( 'text' ) );
$voice = $request->get_param( 'voice' ) ?: 'Bella';
$apikey = 'YOUR_ELEVENLABS_API_KEY';
$response = wp_remote_post( 'https://api.elevenlabs.io/v1/text-to-speech/' . $voice, array(
'headers' => array(
'xi-api-key' => $apikey,
'Content-Type' => 'application/json',
),
'body' => json_encode( array(
'text' => $text,
'model_id' => 'eleven_monolingual_v1',
) ),
) );
if ( is_wp_error( $response ) ) {
return new WP_REST_Response( 'API request failed', 500 );
}
$audio = wp_remote_retrieve_body( $response );
return new WP_REST_Response( $audio, 200, array( 'Content-Type' => 'audio/mpeg' ) );
}
What it does
- Registers
/wp-json/voice/v1/synthesizeas a POST route. - Forwards the
textand optionalvoiceparam to ElevenLabs. - Returns the raw MP3 stream.
Replace
YOUR_ELEVENLABS_API_KEYwith the key you copied earlier.
Step 3 – Front‑end JavaScript to Call the Endpoint
Create a simple page template or shortcode that renders a text box and a “Speak” button.
<div id="voice-ui">
<textarea id="voice-text" rows="4" cols="60" placeholder="Enter text here..."></textarea>
<br>
<button id="speak-btn">Speak</button>
<audio id="voice-player" controls style="display:none;"></audio>
</div>
<script>
document.getElementById('speak-btn').onclick = async () => {
const text = document.getElementById('voice-text').value;
const resp = await fetch('/wp-json/voice/v1/synthesize', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text, voice: 'Bella' })
});
if (!resp.ok) throw new Error('Failed to synthesize');
const blob = await resp.blob();
const url = URL.createObjectURL(blob);
const player = document.getElementById('voice-player');
player.src = url;
player.style.display = 'block';
player.play();
};
</script>
Result – Users type text, click “Speak,” and the browser plays the synthesized voice instantly.
Step 4 – Deploy on Bluehost
- Log into Bluehost.
- Click “Create Site” → choose a theme (or “Blank Site” for a custom layout).
- In the hosting dashboard, go to “File Manager” or “SSH” if you prefer.
- Upload the plugin folder (
voice-synth-api) towp-content/plugins/. - Activate the plugin via the WordPress admin.
- Create a new page, paste the HTML/JS snippet, and publish.
Bluehost’s SSD storage and CDN mean the audio files load instantly, even for global audiences. No manual server configuration required—just click, upload, and go.
👉 Start hosting on Bluehost – get your WordPress site up in minutes.
Optional: Voice Cloning
If you want the app to sound like a specific person, ElevenLabs offers voice cloning:
- Upload a 1‑minute audio sample in the ElevenLabs dashboard.
- Get the voice ID (e.g.,
my_custom_voice). - Pass that ID to the
/synthesizeendpoint instead of the defaultBella.
The same JavaScript code works—just change the voice field.
Tips & Best Practices
| Tip | Why it matters |
|---|---|
| Cache responses | Store the MP3s for frequently requested phrases to cut API costs. |
| Use HTTPS | Bluehost provides free SSL; keep all requests encrypted. |
| Set a rate limit | Protect your API key from abuse; WordPress can throttle requests with a plugin. |
| Monitor usage | ElevenLabs dashboard shows requests per month; stay under the free tier if you’re prototyping. |
| Add a “Download” button | Let users download the MP3 for offline listening. |
Wrap‑Up
You now have a fully functional voice‑AI web app:
- ElevenLabs handles the heavy lifting of speech synthesis.
- WordPress gives you a familiar, low‑maintenance platform.
- Bluehost delivers the hosting with minimal setup and great performance.
No deep cloud expertise required—just a few lines of code, a plugin, and a hosting plan. You can extend this foundation to build chatbots, educational tools, or personalized audio marketing campaigns.
Ready to bring your project to life? Try ElevenLabs for premium voices and host on Bluehost for an affordable, hassle‑free deployment. Happy coding!
Top comments (0)