A FastAPI-based text-to-speech service using NeuTTS Air with full OpenAI TTS streaming API compatibility.
This service is fully compatible with the OpenAI TTS streaming API. Set up as shown below, then use with:
localhost:8000/v1/localhost:8000/v1/localhost:8000/v1/Clone the repository
git clone https://github.com/Edward-Zion-Saji/neutts-openai-api.git
cd neutts-openai-api
Create and activate virtual environment
python -m venv venv
source venv/bin/activate
Install dependencies
pip install -r requirements.txt
Run the application
python openai.py
The API will be available at http://localhost:8000
Clone the repository
git clone https://github.com/Edward-Zion-Saji/neutts-openai-api.git
cd neutts-openai-api
Build the Docker image
docker build -t neutts-openai-api .
Run with GPU support
Option A: Docker run
docker run --gpus all -p 8000:8000 neutts-openai-api
Option B: Docker Compose (recommended)
docker-compose up --build
POST /v1/audio/speech
Request:
{
"input": "Hello, this is a test",
"voice": "coral",
"response_format": "mp3"
}
POST /synthesize - Basic TTS synthesisPOST /synthesize-with-timing - TTS with timing informationGET /health - Health checkGET / - Web interfaceaudio/mpegaudio/wavaudio/pcmaudio/opusaudio/aacaudio/flaccoral - Maps to Dave voicedave - Dave voiceInstall NVIDIA Container Toolkit
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
Verify GPU support
docker run --rm --gpus all nvidia/cuda:12.8-base-ubuntu22.04 nvidia-smi
from pipecat.pipeline.pipeline import Pipeline
from pipecat.services.openai import OpenAILLMService
from pipecat.services.elevenlabs import ElevenLabsTTSService
# Replace OpenAI TTS with NeuTTS
pipeline = Pipeline([
OpenAILLMService(api_key="your-key", model="gpt-4"),
ElevenLabsTTSService(api_key="your-key", voice_id="your-voice")
])
# Change to use local NeuTTS service
pipeline = Pipeline([
OpenAILLMService(api_key="your-key", model="gpt-4"),
ElevenLabsTTSService(api_key="dummy", voice_id="coral", base_url="http://localhost:8000/v1/")
])
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice_assistant import VoiceAssistant
from livekit.plugins import openai
# Configure OpenAI TTS to use local NeuTTS
openai.TTS_BASE_URL = "http://localhost:8000/v1/"
# In your OpenWebUI configuration
openai:
base_url: "http://localhost:8000/v1/"
api_key: "dummy" # Not used by NeuTTS
Documentation available at /docs when the service is running.
4 commits
Python
74.2%
HTML
24.9%
A FastAPI-based text-to-speech service using NeuTTS Air with full OpenAI TTS streaming API compatibility.
This service is fully compatible with the OpenAI TTS streaming API. Set up as shown below, then use with:
localhost:8000/v1/localhost:8000/v1/localhost:8000/v1/Clone the repository
git clone https://github.com/Edward-Zion-Saji/neutts-openai-api.git
cd neutts-openai-api
Create and activate virtual environment
python -m venv venv
source venv/bin/activate
Install dependencies
pip install -r requirements.txt
Run the application
python openai.py
The API will be available at http://localhost:8000
Clone the repository
git clone https://github.com/Edward-Zion-Saji/neutts-openai-api.git
cd neutts-openai-api
Build the Docker image
docker build -t neutts-openai-api .
Run with GPU support
Option A: Docker run
docker run --gpus all -p 8000:8000 neutts-openai-api
Option B: Docker Compose (recommended)
docker-compose up --build
POST /v1/audio/speech
Request:
{
"input": "Hello, this is a test",
"voice": "coral",
"response_format": "mp3"
}
POST /synthesize - Basic TTS synthesisPOST /synthesize-with-timing - TTS with timing informationGET /health - Health checkGET / - Web interfaceaudio/mpegaudio/wavaudio/pcmaudio/opusaudio/aacaudio/flaccoral - Maps to Dave voicedave - Dave voiceInstall NVIDIA Container Toolkit
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
Verify GPU support
docker run --rm --gpus all nvidia/cuda:12.8-base-ubuntu22.04 nvidia-smi
from pipecat.pipeline.pipeline import Pipeline
from pipecat.services.openai import OpenAILLMService
from pipecat.services.elevenlabs import ElevenLabsTTSService
# Replace OpenAI TTS with NeuTTS
pipeline = Pipeline([
OpenAILLMService(api_key="your-key", model="gpt-4"),
ElevenLabsTTSService(api_key="your-key", voice_id="your-voice")
])
# Change to use local NeuTTS service
pipeline = Pipeline([
OpenAILLMService(api_key="your-key", model="gpt-4"),
ElevenLabsTTSService(api_key="dummy", voice_id="coral", base_url="http://localhost:8000/v1/")
])
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice_assistant import VoiceAssistant
from livekit.plugins import openai
# Configure OpenAI TTS to use local NeuTTS
openai.TTS_BASE_URL = "http://localhost:8000/v1/"
# In your OpenWebUI configuration
openai:
base_url: "http://localhost:8000/v1/"
api_key: "dummy" # Not used by NeuTTS
Documentation available at /docs when the service is running.
4 commits
Python
74.2%
HTML
24.9%