Vocalizer is a native PHP extension by Akram Zerarka that brings on-device text-to-speech to PHP without cloud APIs or runtime dependencies. It embeds two inference engines—sherpa-onnx (ONNX Runtime) and audio.cpp (ggml)—and ships as a prebuilt .so binary, so there is nothing to compile. The Laravel News piece by Paul Redmond, dated July 16, 2026, walks PHP developers through why the extension is worth considering for voice-enabled applications.

A single Engine::load() call points to a model directory and auto-detects one of eight supported families: Chatterbox, Supertonic, Piper/VITS, Pocket, Kokoro, Kitten, Matcha, and ZipVoice. Synthesis is a single speak() call, with results that can be saved as a WAV file, returned as a WAV string, or read as float32 PCM. Chatterbox is the most capable option: a single ~7.5 GB model covers 23 languages and can clone a voice from a 3–10 second reference WAV. It also has an anti-hallucination guard that re-synthesizes output with a new seed if it detects skipped text, loops, or silence, defaulting to two retries before throwing a Vocalizer\Exception. Supertonic 3 is aimed at real-time multi-language synthesis across 31 languages, Pocket TTS is lightweight for French/English cloning, and Piper/VITS is the fastest with one model per locale.

Production robustness is built in. Models are cached once per PHP worker with LRU eviction, and synthesis runs in fork mode by default so an engine crash is retried and reloaded rather than killing the FPM worker. Chatterbox is the exception because its ggml thread pool is not fork-safe, so it always runs in direct mode. There is also speakAsync() for off-request synthesis, php.ini controls for isolation, timeout, max_models, and max_concurrency, and per-call timeouts.

Installation is via a curl script that downloads a ~44 MB prebuilt extension and verifies it with SHA256. Requirements are Linux x86-64 with glibc ≥ 2.28 and PHP 8.4 or 8.5 NTS; Alpine/musl, ARM, and ZTS are not supported. Models are downloaded separately, including Chatterbox at ~7.5 GB and Supertonic 3 at ~120 MB. The extension is MIT-licensed and statically links sherpa-onnx (Apache-2.0), audio.cpp/ggml (MIT), ONNX Runtime (MIT), and espeak-ng (GPL-3.0 phonemization data).