Dev.to WebDev 🛠 Dev 👁 0 📖 4 min read

Host Your TTS API Wrapper: Bluehost VPS Setup Guide

Why a VPS Makes Sense for Text‑to‑Speech Projects When you’re building a voice‑AI service—whether it’s a chatbot that talks back, an audiobook generator, or a voice‑cloned product—you’re usually juggling two heavy work

Why a VPS Makes Sense for Text‑to‑Speech Projects

When you’re building a voice‑AI service—whether it’s a chatbot that talks back, an audiobook generator, or a voice‑cloned product—you’re usually juggling two heavy workloads: the TTS engine and the API that sits in front of it. Running both on a single machine can get messy fast. A virtual private server (VPS) lets you isolate the TTS logic, scale independently, and keep your API fast and secure.

Picking a Hosting Provider: Bluehost VS the Competition

There are dozens of VPS hosts out there, but Bluehost stands out for three reasons:

  1. Ease of Use – Their control panel is beginner‑friendly, and the setup wizard gets you to a running instance in minutes.
  2. Affordability – You can start with a low‑tier plan that still gives you a solid amount of RAM and SSD storage, and upgrade on demand.
  3. Developer Support – Bluehost offers 24/7 chat, email, and phone support, plus a wealth of tutorials that cover everything from SSH to Docker.

If you’re ready to spin up a VPS that’s both inexpensive and reliable, check out Bluehost here: https://bluehost.sjv.io/5k0d52

Step 1: Spin Up Your VPS

  1. Log in to your Bluehost account and click Create a VPS.
  2. Choose a region (e.g., US East – Virginia) and a plan that gives you at least 2 GB RAM and 40 GB SSD.
  3. Pick an OS—Ubuntu 20.04 LTS is a solid choice for Python/Node projects.
  4. Finish the wizard. You’ll receive an IP address, root username, and a temporary password.

Once the instance boots, SSH into it:

Use the password you received, then change it immediately:

passwd

Step 2: Harden the Server (Optional but Recommended)

# Update everything
apt update && apt upgrade -y

# Install fail2ban to protect SSH
apt install fail2ban -y
systemctl enable fail2ban
systemctl start fail2ban

# Set up UFW firewall
ufw allow OpenSSH
ufw enable

Step 3: Install Runtime Dependencies

We’ll build a lightweight Python wrapper that talks to ElevenLabs’ TTS API. Install Python 3.10, pip, and virtualenv:

apt install python3.10 python3-pip python3-venv -y

Create a project directory:

mkdir ~/tts-wrapper
cd ~/tts-wrapper
python3 -m venv venv
source venv/bin/activate

Step 4: Get Your ElevenLabs API Key

ElevenLabs offers high‑fidelity voice synthesis and voice cloning. Sign up and grab your key at https://try.elevenlabs.io/kr07zfuqn1bp. Keep it secret—store it in a .env file:

echo "ELEVENLABS_API_KEY=YOUR_KEY_HERE" > .env

Step 5: Build the Wrapper

Create a wrapper.py file:

import os
import json
import requests
from dotenv import load_dotenv

load_dotenv()
API_KEY = os.getenv("ELEVENLABS_API_KEY")
BASE_URL = "https://api.elevenlabs.io/v1"

def synthesize(text, voice_id="en-US-Standard-C"):
    headers = {
        "Accept": "application/json",
        "xi-api-key": API_KEY
    }
    payload = {
        "text": text,
        "voice_settings": {"stability": 0.5, "similarity_boost": 0.75}
    }
    response = requests.post(f"{BASE_URL}/text-to-speech/{voice_id}", headers=headers, json=payload)
    response.raise_for_status()
    return response.content  # raw audio bytes

if __name__ == "__main__":
    sample = "Hello, this is your voice AI coming to life on a Bluehost VPS!"
    audio = synthesize(sample)
    with open("output.mp3", "wb") as f:
        f.write(audio)
    print("Saved to output.mp3")

Install required packages:

pip install requests python-dotenv

Run a quick test:

python wrapper.py

You should see output.mp3 in the folder. Open it to hear the ElevenLabs voice—smooth, natural, and ready for production.

Step 6: Expose an API with Flask

Add a simple web layer so external clients can hit your VPS:

pip install flask

Create app.py:

from flask import Flask, request, send_file
from wrapper import synthesize
import io

app = Flask(__name__)

@app.route("/speak", methods=["POST"])
def speak():
    data = request.json
    text = data.get("text", "")
    if not text:
        return {"error": "No text provided"}, 400
    audio_bytes = synthesize(text)
    return send_file(
        io.BytesIO(audio_bytes),
        mimetype="audio/mpeg",
        as_attachment=True,
        download_name="speech.mp3"
    )

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)

Test it with curl:

curl -X POST https://your.vps.ip.address:5000/speak \
  -H "Content-Type: application/json" \
  -d '{"text":"Testing voice from your VPS!"}' \
  --output test.mp3

Open test.mp3 and you’ll hear the ElevenLabs voice delivered right from your Bluehost server.

Step 7: Run the Service in Production

For a small service, a process manager like systemd or supervisord is enough. Here’s a quick systemd service file:

sudo nano /etc/systemd/system/tts.service

Paste:

[Unit]
Description=ElevenLabs TTS Wrapper Service
After=network.target

[Service]
User=root
WorkingDirectory=/root/tts-wrapper
ExecStart=/root/tts-wrapper/venv/bin/python app.py
Restart=always

[Install]
WantedBy=multi-user.target

Enable and start:

systemctl daemon-reload
systemctl enable tts
systemctl start tts

Your API is now live. Add a domain from Bluehost’s DNS panel and point it to your VPS IP. If you need HTTPS, a free Let's Encrypt certificate via certbot is a breeze.

Scaling and Optimization

  • Dockerize: Containerize the wrapper and API; Bluehost’s VPS supports Docker out of the box.
  • Cache Responses: If you’re synthesizing the same sentences often, store MP3s in Redis or local disk.
  • Load‑Balance: Spin up multiple VPS instances behind a round‑robin DNS or a simple Nginx load balancer.

Final Thoughts

You’ve just turned a raw ElevenLabs API key into a fully‑featured, self‑hosted TTS service running on a Bluehost VPS. The setup is straightforward, the cost is low, and the performance is reliable. Whether you’re powering a personal project, a startup prototype, or a full‑blown voice‑AI product, this architecture gives you control and flexibility.

Ready to bring your voice AI to life? Sign up for ElevenLabs today: https://try.elevenlabs.io/kr07zfuqn1bp

Need a dependable, affordable VPS? Get started with Bluehost: https://bluehost.sjv.io/5k0d52

Happy coding, and may your voices sound as clear as your ideas!

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.