DEV Community

VoiceDeveloper
VoiceDeveloper

Posted on

Host Your TTS API Wrapper: Bluehost VPS Setup Guide

Why Build Your Own TTS Wrapper?

Voice AI is exploding across chatbots, accessibility tools, audiobooks, and even personalized marketing. The core of most voice projects is a Text‑to‑Speech (TTS) service that turns plain text into natural‑sounding audio. Instead of calling the raw API every time, a lightweight wrapper gives you:

  • Caching for frequently used phrases
  • Custom headers (e.g., user‑specific voice settings)
  • Rate‑limit handling so you don’t hit service limits unexpectedly
  • A single point to swap providers if you ever need to

If you’re looking for a high‑quality TTS engine, ElevenLabs is a standout choice. Their neural voices are industry‑leading, and they expose a simple REST interface that works well in any language.

Tip: Sign up with the affiliate link https://try.elevenlabs.io/kr07zfuqn1bp to get a free tier and a discount on higher plans.

Why Bluehost VPS for Your Wrapper?

When you’re ready to expose your wrapper as a production‑ready service, you need a server that’s:

  • Affordable – $5–$10/month for a single core VPS
  • Managed – automatic updates, backups, and a friendly control panel
  • Developer‑friendly – SSH access, Docker support, and the ability to install any language runtime

Bluehost offers all of that with a straightforward setup flow. Their VPS plans are priced at just a few dollars a month, and the platform is optimized for small to medium workloads. If you’re looking for an easy, cost‑effective way to host your voice AI project, Bluehost is a solid pick.

Pro tip: Grab your VPS with the affiliate link https://bluehost.sjv.io/5k0d52 and enjoy a free domain for the first year.

Step‑by‑Step: Deploying the Wrapper on a Bluehost VPS

Below is a minimal, repeatable workflow that works on any Linux‑based VPS (Ubuntu 22.04 is assumed). Feel free to adapt the commands for your preferred distribution.

1. Spin Up the VPS

  1. Sign up at https://bluehost.sjv.io/5k0d52.
  2. Choose a 1‑core, 1 GB RAM instance (good enough for most TTS workloads).
  3. Complete the payment and wait for the server to be provisioned.
  4. SSH into the machine:
ssh root@your-vps-ip
Enter fullscreen mode Exit fullscreen mode

If you’re on Windows, use PuTTY or the built‑in OpenSSH client in PowerShell.

2. Harden the Server (Optional but Recommended)

# Update packages
apt update && apt upgrade -y

# Install UFW firewall
apt install ufw -y
ufw allow OpenSSH
ufw enable

# Install fail2ban for SSH protection
apt install fail2ban -y
systemctl enable fail2ban
systemctl start fail2ban
Enter fullscreen mode Exit fullscreen mode

3. Install Dependencies

We’ll use Python 3.11 for the wrapper and Gunicorn + NGINX for serving.

# Install Python and pip
apt install python3 python3-pip python3-venv -y

# Create a project directory
mkdir ~/tts-wrapper
cd ~/tts-wrapper

# Set up a virtual environment
python3 -m venv venv
source venv/bin/activate
Enter fullscreen mode Exit fullscreen mode

4. Pull the Wrapper Code

Assuming you have a GitHub repo (replace your-repo with your actual repo name):

git clone https://github.com/your-username/your-repo.git .
Enter fullscreen mode Exit fullscreen mode

If you don’t have a repo yet, create a simple Flask app. Here’s a quick starter:

# app.py
import os
from flask import Flask, request, jsonify
import requests

app = Flask(__name__)

ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY")
ELEVENLABS_ENDPOINT = "https://api.elevenlabs.io/v1/text-to-speech"

@app.route("/speak", methods=["POST"])
def speak():
    data = request.json
    text = data.get("text")
    voice_id = data.get("voice_id", "Rachel")  # default voice

    headers = {
        "xi-api-key": ELEVENLABS_API_KEY,
        "Content-Type": "application/json"
    }

    payload = {
        "text": text,
        "voice_id": voice_id,
        "model_id": "eleven_monolingual_v1",
        "output_format": "mp3"
    }

    resp = requests.post(ELEVENLABS_ENDPOINT, json=payload, headers=headers)
    if resp.status_code != 200:
        return jsonify({"error": resp.text}), resp.status_code

    return resp.content, 200, {"Content-Type": "audio/mpeg"}

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)
Enter fullscreen mode Exit fullscreen mode

Install requirements

pip install flask requests gunicorn
Enter fullscreen mode Exit fullscreen mode

5. Configure Environment Variables

Create a .env file:

cat > .env <<EOF
ELEVENLABS_API_KEY=your_api_key_here
EOF
Enter fullscreen mode Exit fullscreen mode

Load it in your app.py or use a tool like python-dotenv:

pip install python-dotenv
Enter fullscreen mode Exit fullscreen mode

Add at the top of app.py:

from dotenv import load_dotenv
load_dotenv()
Enter fullscreen mode Exit fullscreen mode

6. Run the App with Gunicorn

gunicorn --workers 3 --bind 0.0.0.0:8000 app:app
Enter fullscreen mode Exit fullscreen mode

You should see Gunicorn listening on port 8000.

7. Set Up NGINX Reverse Proxy

apt install nginx -y

# Create a new site config
cat > /etc/nginx/sites-available/tts_wrapper <<EOF
server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
EOF

# Enable the site
ln -s /etc/nginx/sites-available/tts_wrapper /etc/nginx/sites-enabled/
nginx -t && systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

If you have a domain, point its A record to your VPS IP. If not, you can test with the IP address.

8. Test the Endpoint

curl -X POST http://your-domain.com/speak \
     -H "Content-Type: application/json" \
     -d '{"text":"Hello, world!","voice_id":"Rachel"}' \
     --output hello.mp3
Enter fullscreen mode Exit fullscreen mode

You should get an hello.mp3 file that you can play locally.

Scaling and Production Tips

Area Recommendation
Process Management Use systemd to keep Gunicorn alive.
HTTPS Obtain a free Let’s Encrypt cert: certbot --nginx -d your-domain.com.
Caching Store frequent phrases in Redis or a simple file cache.
Rate‑Limiting Add a middleware to throttle requests per IP.
Monitoring Install htop, glances, or use Bluehost’s dashboard.

systemd Service Example

cat > /etc/systemd/system/tts_wrapper.service <<EOF
[Unit]
Description=TTS Wrapper Service
After=network.target

[Service]
User=root
WorkingDirectory=/home/root/tts-wrapper
ExecStart=/home/root/tts-wrapper/venv/bin/gunicorn --workers 3 --bind 0.0.0.0:8000 app:app
Restart=always

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable tts_wrapper
systemctl start tts_wrapper
Enter fullscreen mode Exit fullscreen mode

Now you have a robust, production‑ready TTS wrapper running on a Bluehost VPS.

Final Thoughts

You’ve learned how to:

  1. Spin up a budget‑friendly Bluehost VPS.
  2. Secure it with basic firewall rules.
  3. Deploy a Python/TTS wrapper that talks to ElevenLabs.
  4. Expose the service behind NGINX with HTTPS.

All of this can be done in under an hour if you’re comfortable with the command line. The result? A scalable, low‑cost voice AI backend that can be integrated into chat apps, accessibility tools, or any project that needs natural speech output.

Ready to Take the Next Step?

If you haven’t already, sign up with https://try.elevenlabs.io/kr07zfuqn1bp to start generating high‑quality voices. Then host your wrapper on a reliable, affordable VPS from https://bluehost.sjv.io/5k0d52 and enjoy the freedom of full control over your voice AI stack. Happy coding!

Top comments (0)