New Tool Radar

Local AI

How to Generate Speech with a LocalAI Text-to-Speech Model

Install a text-to-speech model in LocalAI, send text to its speech endpoint, and save the spoken audio as a WAV file.

Schematic diagram with three steps: install the omnivoice-cpp model, send text to the /v1/audio/speech endpoint, then listen to the saved speech.wav file.

LocalAI can turn text into spoken audio with a text-to-speech model running on your own machine. The LocalAI text-to-speech API is compatible with the OpenAI TTS API and the ElevenLabs API, so the same request shape works here as with those services — but the model and the audio stay local. You send text and a model name to an endpoint, and you get an audio file back.

Install a text-to-speech model

Install the omnivoice-cpp model in the Model gallery, or run this command:

local-ai models install omnivoice-cpp

OmniVoice is a native C++ text-to-speech engine served by the omnivoice-cpp backend. It supports voice cloning from reference audio plus its transcript, voice design by steering the voice with attribute keywords, and streaming synthesis. Its output is 24kHz mono audio. A higher-quality BF16 variant is available as omnivoice-cpp-hq; the default omnivoice-cpp ships Q8_0 GGUF files.

Send text to the speech endpoint

Use the /v1/audio/speech endpoint with the model name and the text to speak, and save the reply to a file:

curl http://localhost:8080/v1/audio/speech -H "Content-Type: application/json" -d '{
     "model": "omnivoice-cpp",
     "input": "Hello world, this is a test."
   }' --output speech.wav

The docs also give a LocalAI endpoint for the same job: send a POST request to /tts with input and model, and it returns an audio/wav file. You can also describe how the text should be delivered with the optional instructions property on /v1/audio/speech, for example "Speak slowly and warmly." — but backend support for speech instructions varies, and backends that do not support this control may ignore it.

List the voices and check the file

To see which named voices your installed text-to-speech models offer, use this endpoint:

curl http://localhost:8080/v1/audio/voices

Add the model query parameter to return one installed model, for example curl 'http://localhost:8080/v1/audio/voices?model=pocket-tts'. Each voice can include language and gender metadata. LocalAI returns 404 when the requested model is not installed, so a 404 here means the model name is wrong or the model is not installed yet. Then play the file you saved: the docs pipe audio to aplay on Linux and note that aplay is a Linux command, so use another audio player on other systems. Open speech.wav and listen for the sentence you sent.

Try it: four checks from install to spoken audio

Check What you should see If you do not see it
Model installed omnivoice-cpp listed among your installed models Run local-ai models install omnivoice-cpp again and wait for the download
Voices listed GET /v1/audio/voices returns a list of voices A 404 means the model is not installed — check the model name
Audio file saved A speech.wav file in your folder after the curl request Check the request used /v1/audio/speech with --output speech.wav
Speech plays The file plays back the sentence “Hello world, this is a test.” Check the file is not empty, then try another audio player

Expected result. We checked the LocalAI audio and speech docs page, which gives the OpenAI and ElevenLabs API compatibility, the /tts endpoint returning an audio/wav file, the /v1/audio/speech example with the omnivoice-cpp model and the –output speech.wav flag, the instructions property with the “Speak slowly and warmly.” example and the note that backend support varies, the local-ai models install omnivoice-cpp command, the 24kHz mono output, the GET /v1/audio/voices endpoint with the pocket-tts example and the 404 rule, and the aplay note for Linux. We did not install LocalAI or generate any speech on this machine.

Limits

This guide covers one text-to-speech model and one spoken file only. Voice cloning needs a reference audio clip and its transcript, and the voice library’s cloning profiles have their own setup; those are separate jobs. The instructions field is optional and may be ignored by backends that do not support it. For long texts, the docs show streaming synthesis with "stream": true in the request, piped to a player so playback starts before generation finishes. Piper voices are a separate manual install: the docs say to download voices from the Piper releases page and extract the files into the models folder, and that LocalAI must be compiled with the GO_TAGS=tts flag for Piper. We did not run any of this ourselves.

Sources

See all