Run Qwen3-TTS Locally with llama.cpp v1.1.0: Voice Cloning, GGUF and an OpenAI-Compatible API (2026 Guide)
You do not need a hosted speech API to turn application text into audio. With the tagged llama.cpp v1.1.0 build and the Qwen3-TTS 1.7B Base GGUF, you can synthesize speech on your own machine, condition it on a voice sample you are authorized to use, and expose a local HTTP endpoint that existing applications can call. The result is a compact, self-hosted text-to-speech service rather than another cloud dependency.
This is a hands-on companion to the llama.cpp v1.1.0 release coverage: the focus here is one complete workflow, from building the binaries and downloading the model to generating a WAV file, starting an API server, calling it from Python, and protecting the voice-reference data. It is deliberately different from a general speech platform such as Speaches: this guide uses llama.cpp's GGUF runtime and its own llama-tts and llama-server tools.
What you will build
- A pinned llama.cpp v1.1.0 build with the TTS and server executables.
- A local Qwen3-TTS 12Hz 1.7B Base GGUF model in Q4_K_M quantization.
- A CLI workflow that generates a WAV file from text and an authorized speaker-reference clip.
- A loopback-only
llama-serverexposingPOST /ttsand the OpenAI-compatiblePOST /v1/audio/speechroute. - A small Python client that uploads the reference audio and saves the generated speech.
Important model distinction: this walkthrough uses the Base model, which is intended for reference-audio voice cloning. It is not the same as Qwen3-TTS CustomVoice, which offers a fixed speaker catalogue and instruction-based style control, or VoiceDesign, which creates a voice from a natural-language description. Choose the variant that matches the task instead of assuming every Qwen3-TTS model accepts the same parameters.
Prerequisites
- Operating system: Linux or macOS is the simplest path for the commands below. Windows users can follow the same source build inside WSL2, or use a Windows package only after confirming it contains the required
llama-ttsandllama-serverexecutables. - Build tools: Git, CMake, a C/C++ compiler and the platform's normal build dependencies.
- Storage: allow space for the llama.cpp build, the model, its multimodal projector when supplied, a speaker clip and generated WAV files. The Q4_K_M talker file shown on the model page is about 1.04 GB; other quantizations are larger.
- Hardware: CPU inference is possible but may be slow. A supported GPU backend can help; the usable model size and speed depend on available memory, drivers and backend support. Do not treat a model file's download size as its full runtime-memory requirement.
- Audio: a short, clean WAV or MP3 recording of a speaker whose voice you have permission to use. For the transcript-conditioned path, keep the reference clip at or below 30 seconds and provide an accurate transcript.
- Network: internet access for the first source/model download. After the model files are cached, inference can run locally.
Step 1 — Check the model and language fit
Qwen's official model documentation lists ten supported languages for the Qwen3-TTS family: Chinese, English, Japanese, Korean, German, French, Russian, Portuguese, Spanish and Italian. Hindi is not in that documented list, so do not assume this particular model is a Hindi TTS solution. Test the exact language, accent, names and pronunciation that your application needs before adopting it.
The Base variant supports reference-audio cloning. Qwen describes a rapid three-second reference workflow, while llama.cpp's tagged documentation explains how a reference clip and its transcript can be supplied. A transcript can help the model condition on the reference speech more closely; it must actually match the audio.
For this guide, use the GGUF repository maintained by the llama.cpp organization:
Q4_K_M is a sensible first download for a constrained local setup. Q8_0 and BF16 are also listed on the GGUF model page and require more storage. A smaller file does not guarantee a specific quality or speed improvement on your hardware; compare outputs with your own representative sentences.
Step 2 — Build llama.cpp v1.1.0
Pin the source checkout to the stable release tag rather than building an unpinned moving branch. The v1.1.0 release was published on 26 November 2026. Its release notes describe a broad expansion of audio/TTS support, and the documentation at the same tag lists Qwen3-TTS, the llama-tts utility and the server speech endpoints.
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp
git checkout v1.1.0
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j
The default build is the CPU-oriented starting point. On Linux with a compatible NVIDIA CUDA toolkit, configure a separate CUDA build:
cmake -B build-cuda -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=ON
cmake --build build-cuda --config Release -j
On Apple Silicon, use the normal macOS build and check the build output for the Metal backend. Backend availability depends on the platform and installed toolchain; do not copy CUDA flags to a Mac. For AMD GPUs, follow the tagged build guide's HIP/ROCm instructions and choose the target supported by your installed ROCm version.
Confirm that the tools were produced before downloading model weights:
./build/bin/llama-tts --help
./build/bin/llama-server --help
If you used the CUDA build directory, use ./build-cuda/bin/ in the commands below. If one of these executables is missing, revisit the build output and the release's build instructions instead of silently substituting a binary from another version.
Step 3 — Prepare a clean speaker reference
Record or select a short sample in which one person speaks clearly, without music, overlapping speakers, strong reverberation or background conversation. A clean reference is more useful than a long noisy recording. If you convert a source file, keep the conversion simple and preserve the original so you can compare it later:
ffmpeg -i reference-original.m4a \
-ac 1 -c:a pcm_s16le speaker.wav
Listen to speaker.wav before using it. Write down exactly what is spoken if you plan to use transcript conditioning. Punctuation can be normalized, but do not invent words or use a transcript from a different recording.
Consent matters: use your own voice or a speaker who has explicitly agreed to this use. Do not clone a colleague, customer, public figure or family member from a recording simply because you can access it. Keep the source clip private, do not publish it with the model, and clearly disclose synthetic speech when listeners could mistake it for a real recording.
Step 4 — Generate your first WAV with llama-tts
The tagged llama.cpp TTS guide documents Qwen3-TTS support through llama-tts. The -hf option downloads the selected GGUF repository; the :Q4_K_M suffix selects the quantization shown on the model page.
./build/bin/llama-tts \
-hf ggml-org/Qwen3-TTS-12Hz-1.7B-Base-GGUF:Q4_K_M \
-p "Hello. This is a locally generated speech sample." \
--tts-lang en \
--tts-speaker-file speaker.wav \
--output hello-local.wav
For the transcript-conditioned reference path, add the words actually spoken in speaker.wav:
./build/bin/llama-tts \
-hf ggml-org/Qwen3-TTS-12Hz-1.7B-Base-GGUF:Q4_K_M \
-p "Your application text goes here." \
--tts-lang en \
--tts-speaker-file speaker.wav \
--tts-speaker-text "The exact words spoken in the reference clip." \
--output generated.wav
The tagged documentation notes that the transcript-conditioned Qwen3-TTS reference path requires a clip of 30 seconds or less and an mmproj converted with the speech-tokenizer encoder. If that projector is not available in the expected form, llama.cpp falls back to speaker-embedding-only conditioning. In other words, the presence of a transcript flag does not prove that the full reference-code path was used.
Check the generated file:
file generated.wav
ffprobe -hide_banner generated.wav
Listen to the whole output, not just the first second. Check pronunciation of names, numbers, abbreviations and punctuation. Keep the input text short while debugging so that a malformed reference or a model-loading problem is not confused with long-form generation quality.
Step 5 — Start a local speech API
For application integration, start llama-server with the same GGUF repository and an API model alias. The server documentation describes -hf model loading and automatic download of an available multimodal projector. Bind to loopback so the service is reachable only from the same machine:
./build/bin/llama-server \
-hf ggml-org/Qwen3-TTS-12Hz-1.7B-Base-GGUF:Q4_K_M \
--alias tts \
--host 127.0.0.1 \
--port 8080
For a CUDA build, use the CUDA binary and add a suitable GPU offload setting, for example -ngl 99, then watch the startup log to confirm which layers and devices were actually selected. The example is a starting point, not a promise that every layer fits on every GPU.
In a second terminal, check readiness:
curl -i http://127.0.0.1:8080/health
A successful health response is 200 with a ready status. A 503 response can mean the model is still loading. Wait for initialization to finish before sending speech requests.
Step 6 — Call the raw /tts endpoint with a reference file
The raw POST /tts endpoint returns audio bytes. The tagged server documentation supports a multipart speaker_ref upload and the optional speaker_ref_text transcript field. This is the most straightforward way to send a local reference file without manually converting it to Base64:
curl -X POST http://127.0.0.1:8080/tts \
-F "input=Welcome to our locally hosted speech service." \
-F "lang=en" \
-F "speaker_ref_text=The exact words spoken in the reference clip." \
-F "[email protected];type=audio/wav" \
-o api-speech.wav
The server's documented TTS request options include language, reference audio, reference transcript, sampling controls, a seed, output format and streaming. Parameters are model-specific: do not copy every option from another TTS model into Qwen3-TTS and expect it to work. Start with the minimal request, then add one supported parameter at a time.
Inspect the output:
ffprobe -hide_banner api-speech.wav
sha256sum api-speech.wav
Keep the generated file and a small request log during development, but do not log raw reference audio, full transcripts or API secrets in production logs.
Step 7 — Use the OpenAI-compatible speech route
llama.cpp v1.1.0 documents POST /v1/audio/speech as an OpenAI-compatible speech route. It accepts the text input and can forward TTS options such as language and speaker-reference data. The compatibility is useful, but it is not identical to every hosted provider: the tagged documentation lists WAV or PCM output, uses the model's native sample rate, does not map OpenAI voice names such as alloy, and ignores the instructions field.
For a simple request without a reference file:
curl http://127.0.0.1:8080/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{
"model": "tts",
"input": "This audio was generated by a local Qwen3 TTS model.",
"lang": "en",
"response_format": "wav"
}' \
-o openai-compatible.wav
To include a reference through JSON, Base64-encode the audio and send it using the documented speaker_ref_b64 TTS option. For requests that need a reference transcript or multipart file upload, the raw /tts route is easier to inspect and debug. When using a client SDK, check that it preserves provider-specific extra fields; some SDK method signatures filter unknown parameters unless an extra-body mechanism is used.
Step 8 — Call the server from Python
The following example uses httpx and the raw multipart endpoint. It sends the reference file and transcript, checks for an HTTP error, and writes the returned bytes to disk:
python -m venv .venv
source .venv/bin/activate
python -m pip install httpx
import os
from pathlib import Path
import httpx
BASE_URL = "http://127.0.0.1:8080"
TEXT = "Your local application can generate speech without a hosted TTS provider."
REFERENCE_TEXT = "The exact words spoken in the reference clip."
headers = {}
api_key = os.getenv("LLAMA_API_KEY")
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
with Path("speaker.wav").open("rb") as reference:
response = httpx.post(
f"{BASE_URL}/tts",
data={
"input": TEXT,
"lang": "en",
"speaker_ref_text": REFERENCE_TEXT,
},
files={
"speaker_ref": ("speaker.wav", reference, "audio/wav"),
},
headers=headers,
timeout=600.0,
)
response.raise_for_status()
Path("python-speech.wav").write_bytes(response.content)
print("Saved python-speech.wav", len(response.content), "bytes")
Run the script from the directory containing speaker.wav. If the server was started without an API key, the Authorization header is omitted. If you enabled authentication, export LLAMA_API_KEY in the client environment and configure the same key on the server.
Step 9 — Add authentication and keep the service private
llama-server supports an API key through --api-key or the LLAMA_API_KEY environment variable. For a local-only development process, loopback binding is the safest starting point. If you intentionally allow another machine to connect, add authentication and put the service behind a TLS-terminating reverse proxy or a private network access layer.
export LLAMA_API_KEY="replace-with-a-long-random-secret"
./build/bin/llama-server \
-hf ggml-org/Qwen3-TTS-12Hz-1.7B-Base-GGUF:Q4_K_M \
--alias tts \
--host 127.0.0.1 \
--port 8080 \
--api-key "$LLAMA_API_KEY"
Do not bind to 0.0.0.0 just to make a client connection work. First confirm that the client and server are on the same host; if they are in separate containers, use a private container network and bind only as broadly as that network requires. Never expose an unauthenticated TTS server directly to the public internet.
Choosing between llama.cpp, Speaches and a desktop TTS app
| Option | Best fit | Trade-off |
|---|---|---|
| llama.cpp + Qwen3-TTS GGUF | Developers who want a GGUF-based local runtime, CLI generation and a local HTTP endpoint | Model-specific flags and compatibility details need attention |
| Speaches | Applications that need a broader OpenAI-compatible audio service with transcription and multiple speech engines | It is a separate server and model ecosystem |
| LocalText2Voice | Long-form scripts, audiobooks, chapter review and desktop narration workflows | It is an orchestration app rather than this minimal inference server |
If your next task is speech recognition rather than synthesis, see the GyanAangan guides to self-hosting Speaches and local WhisperX meeting transcription. For long-form narration and project review, the LocalText2Voice guide covers a different workflow. If you are building a live phone or browser voice agent, start with the voice-agent architecture comparison.
Troubleshooting
llama-ttsis missing: verify that you checked outv1.1.0, rebuilt the project and inspectedbuild/bin. Do not assume a package containingllama-serveralso contains the TTS utility.- Model download fails: check Hugging Face connectivity, available disk space and the exact repository/quant name. Retry with the model page open beside the terminal so you can confirm the file variant.
- Projector or multimodal loading error: inspect the startup log and confirm that the model repository provides the required projector files. For transcript-conditioned Qwen3-TTS, the tagged documentation specifically calls out a speech-tokenizer-encoder projector requirement.
- Output is silent or nearly silent: verify that you are using the Qwen3-TTS Base model, that the reference clip is readable and contains speech, and that you supplied a valid reference file. Compare one CLI request with one API request.
- Voice changes between generations: use the same authorized reference clip for each request. The Base model is reference-conditioned; it is not a fixed-speaker catalogue model.
- Transcript conditioning seems ineffective: check the transcript against the exact clip, keep the clip within the documented 30-second limit, and verify the correct projector path. The implementation can fall back to speaker-embedding-only conditioning.
- API returns 401: check the configured server API key and send the matching Bearer token. Do not paste the secret into a shared shell transcript or source file.
- API returns 400 for an option: remove optional sampling or voice parameters and retry with only input, language and reference. Some fields are supported only by particular TTS models.
- Audio plays at the wrong speed or format: inspect the WAV header and sample rate with
ffprobe. The OpenAI-compatible route does not resample every model to a universal rate. - Generation is slow or runs out of memory: try a smaller quantization, lower GPU offload, shorter text and a smaller batch. Watch the runtime logs; the model file size is not the complete memory requirement.
Security, consent and production checklist
- Use reference recordings only when you own the voice or have documented permission for the intended use.
- Do not use synthetic speech to impersonate someone, bypass identity checks, fabricate evidence or mislead a recipient.
- Tell listeners when generated speech could reasonably be mistaken for a real person's recording.
- Keep reference audio, transcripts, generated files and API keys out of public repositories and application logs.
- Bind to loopback by default. For remote access, use authentication, TLS, firewall rules and a private network or gateway.
- Set request-size, text-length, concurrency and timeout limits in the application layer. A local model can still be exhausted by unbounded requests.
- Review the code and model licences and any separate voice-data rights before redistributing an application or generated audio commercially.
- Keep the llama.cpp source tag and model revision recorded so a later update does not silently change your production output.
FAQ
Is Qwen3-TTS running locally?
After the source build and model/projector downloads are complete, inference can run on the local machine. The first download still requires network access unless the required files have already been cached or copied to the machine.
Does the Base model have built-in named voices?
No. This guide uses the Base reference-audio model. CustomVoice is the Qwen3-TTS variant for a fixed speaker catalogue and style instructions; VoiceDesign is for describing a new voice.
Can I use Hindi?
Hindi is not among the ten languages listed in the official Qwen3-TTS model documentation used for this guide. Do not advertise Hindi support without testing a model that explicitly supports it.
Can I use the OpenAI Python SDK?
The server documents an OpenAI-compatible /v1/audio/speech endpoint. Standard speech requests can use that route, but model-specific reference-audio fields may require an SDK extra-body mechanism or a direct HTTP call to /tts. The multipart httpx example above is explicit and easier to debug.
Does the server return MP3?
The tagged llama.cpp documentation lists WAV and PCM for the OpenAI-compatible speech route. Do not assume MP3 support. Convert the resulting WAV with FFmpeg if your application needs another format.
Is voice cloning always accurate?
No. Similarity and pronunciation depend on the reference quality, language, text, model quantization and runtime. Review the entire output and never treat a generated voice as proof of a person's identity.
Official references and version notes
- llama.cpp v1.1.0 release notes — stable release published 26 November 2026.
- llama.cpp v1.1.0 TTS documentation — supported models, Qwen3-TTS flags and reference-audio conditions.
- llama-tts README at v1.1.0 — CLI usage and speaker-reference recommendation.
- llama-server README at v1.1.0 —
/tts,/v1/audio/speech, authentication, model loading and server options. - llama.cpp build guide at v1.1.0 — CMake and backend-specific build instructions.
- Qwen3-TTS 1.7B Base GGUF model page — GGUF variants and llama.cpp usage.
- QwenLM/Qwen3-TTS — official model variants, language list, voice-cloning examples and Apache-2.0 project licence.
Version and testing caveat: this guide pins llama.cpp v1.1.0 and uses the matching tagged documentation. Commands and request fields were checked against those sources, but this article was not executed on physical hardware. Build dependencies, GPU support and runtime memory vary by operating system and device. Confirm the model card, licence and release notes again before deploying a later version.
