A simple and fast Docker implementation of the neutts-air Text-to-Speech model, served via a FastAPI backend. This project is designed to eliminate complex setup and allow anyone to easily run and experiment with high-quality TTS locally in minutes.
1
stars
11
commits
Python
primary language
Oct 24, 2025
updated
This project provides a local Text-to-Speech (TTS) service that can clone a voice from an audio sample and then generate speech in that same voice. It is designed to be a self-contained service that you can run locally.
You can try out the neutts-air model live on Hugging Face Spaces
The service uses the NeuTTS-Air model for voice cloning and speech synthesis. When the service starts, it pre-loads and caches voice references from the audio samples provided in the app/samples directory.
The core logic is exposed via a FastAPI server, which provides API endpoints to generate speech from text using one of the pre-cached voices. The entire application is containerized using Docker for easy setup and deployment.
NeuTTS-AirFastAPIlibrosa, soundfilephonemizerDocker[!NOTE] Performance Considerations : For optimal performance, it is recommended to run this service in a Linux environment where Docker is installed natively. When running on Windows or macOS via Docker Desktop, the service may experience significantly slower performance due to the overhead of the underlying virtual machine.
Before building the Docker image, you need to download the pre-trained models. The save_models.py script will download and save the necessary model files into the app/neuttsair/local_models directory.
Navigate to the app/neuttsair directory and run the script:
cd app/neuttsair
python save_models.py
Once the models are downloaded, you can build the Docker image. Navigate back to the root of the project and run the following command:
docker build -t tts-service .
This will build a Docker image with the tag tts-service.
After the image is built, you can run it as a container. The following command will start the container and map the service's port (8000) to the same port on your host machine.
docker run -p 8000:8000 tts-service
The TTS service will now be running and accessible at http://localhost:8000.
You can configure the service to use your own voice by following these steps:
Record a sample of your voice, keeping the following guidelines in mind for the best results:
.wav file..wav file in the app/samples directory. For example, name it my_voice.wav..txt) containing the exact transcript of your recording. The name of the text file should match the name of your .wav file. For example, if your audio file is my_voice.wav, the transcript file should be my_voice.txt.app/samples directory.The service will automatically detect and load new voices from the samples directory.
To use your voice, simply make an API call and set the voice_type parameter to the name of your audio file (without the .wav extension).
For example, if you added my_voice.wav and my_voice.txt to the app/samples directory, you would use "my_voice" as the voice_type:
Request Body:
{
"text": "This is a test of my own voice.",
"voice_type": "my_voice"
}
The service will find your audio sample, encode it, cache it for future requests, and use it to generate the speech.
The service exposes the following endpoints:
POST /generate-tts-base64/{
"text": "Hello, world. This is a test.",
"voice_type": "MALE"
}
text (string, required): The text to be converted to speech. Must be between 3 and 500 characters.voice_type (string, required): The voice to use for the synthesis. Can be either "MALE" or "FEMALE".{
"audio_base64": "UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAAABkYXRhIAAAAA...",
"input_text": "Hello, world. This is a test.",
"voice_type": "MALE"
}
audio_base64 (string): The Base64 encoded WAV audio data.input_text (string): The input text that was synthesized.voice_type (string): The voice type used for the synthesis.POST /generate-tts-file/.wav file. This is useful for directly downloading the audio file.{
"text": "Hello, world. This is a test.",
"voice_type": "FEMALE"
}
text (string, required): The text to be converted to speech. Must be between 3 and 500 characters.voice_type (string, required): The voice to use for the synthesis. Can be either "MALE" or "FEMALE"..wav audio file with the Content-Disposition header set to attachment; filename=output.wav.GET /{
"message": "NeuTTS-Air API is running."
}
This project uses the open-source neutts-air model from neuphonic. You can find the original repository here: Neutts-Air
11 commits
Python
97.2%
Dockerfile
2.8%
A simple and fast Docker implementation of the neutts-air Text-to-Speech model, served via a FastAPI backend. This project is designed to eliminate complex setup and allow anyone to easily run and experiment with high-quality TTS locally in minutes.
1
stars
11
commits
Python
primary language
Oct 24, 2025
updated
This project provides a local Text-to-Speech (TTS) service that can clone a voice from an audio sample and then generate speech in that same voice. It is designed to be a self-contained service that you can run locally.
You can try out the neutts-air model live on Hugging Face Spaces
The service uses the NeuTTS-Air model for voice cloning and speech synthesis. When the service starts, it pre-loads and caches voice references from the audio samples provided in the app/samples directory.
The core logic is exposed via a FastAPI server, which provides API endpoints to generate speech from text using one of the pre-cached voices. The entire application is containerized using Docker for easy setup and deployment.
NeuTTS-AirFastAPIlibrosa, soundfilephonemizerDocker[!NOTE] Performance Considerations : For optimal performance, it is recommended to run this service in a Linux environment where Docker is installed natively. When running on Windows or macOS via Docker Desktop, the service may experience significantly slower performance due to the overhead of the underlying virtual machine.
Before building the Docker image, you need to download the pre-trained models. The save_models.py script will download and save the necessary model files into the app/neuttsair/local_models directory.
Navigate to the app/neuttsair directory and run the script:
cd app/neuttsair
python save_models.py
Once the models are downloaded, you can build the Docker image. Navigate back to the root of the project and run the following command:
docker build -t tts-service .
This will build a Docker image with the tag tts-service.
After the image is built, you can run it as a container. The following command will start the container and map the service's port (8000) to the same port on your host machine.
docker run -p 8000:8000 tts-service
The TTS service will now be running and accessible at http://localhost:8000.
You can configure the service to use your own voice by following these steps:
Record a sample of your voice, keeping the following guidelines in mind for the best results:
.wav file..wav file in the app/samples directory. For example, name it my_voice.wav..txt) containing the exact transcript of your recording. The name of the text file should match the name of your .wav file. For example, if your audio file is my_voice.wav, the transcript file should be my_voice.txt.app/samples directory.The service will automatically detect and load new voices from the samples directory.
To use your voice, simply make an API call and set the voice_type parameter to the name of your audio file (without the .wav extension).
For example, if you added my_voice.wav and my_voice.txt to the app/samples directory, you would use "my_voice" as the voice_type:
Request Body:
{
"text": "This is a test of my own voice.",
"voice_type": "my_voice"
}
The service will find your audio sample, encode it, cache it for future requests, and use it to generate the speech.
The service exposes the following endpoints:
POST /generate-tts-base64/{
"text": "Hello, world. This is a test.",
"voice_type": "MALE"
}
text (string, required): The text to be converted to speech. Must be between 3 and 500 characters.voice_type (string, required): The voice to use for the synthesis. Can be either "MALE" or "FEMALE".{
"audio_base64": "UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAAABkYXRhIAAAAA...",
"input_text": "Hello, world. This is a test.",
"voice_type": "MALE"
}
audio_base64 (string): The Base64 encoded WAV audio data.input_text (string): The input text that was synthesized.voice_type (string): The voice type used for the synthesis.POST /generate-tts-file/.wav file. This is useful for directly downloading the audio file.{
"text": "Hello, world. This is a test.",
"voice_type": "FEMALE"
}
text (string, required): The text to be converted to speech. Must be between 3 and 500 characters.voice_type (string, required): The voice to use for the synthesis. Can be either "MALE" or "FEMALE"..wav audio file with the Content-Disposition header set to attachment; filename=output.wav.GET /{
"message": "NeuTTS-Air API is running."
}
This project uses the open-source neutts-air model from neuphonic. You can find the original repository here: Neutts-Air
11 commits
Python
97.2%
Dockerfile
2.8%