Skip to main content

Basic speech synthesis

The following talk.php demonstrates how to synthesize speech from text and write it to a WAV file.
PHP FFI is usually disabled in web server environments such as FPM. Run this script from the CLI with php talk.php.
Run it:

One-step synthesis with tts

If you want to skip the two-step createAudioQuery + synthesis flow, use the tts() method:

Synthesis from kana notation

You can also synthesize from AquesTalk-style kana notation:

Using a user dictionary

Use UserDict to register custom word pronunciations:

Adjusting AudioQuery

You can fine-tune the intonation and tempo by modifying the JSON returned by createAudioQuery before synthesis:

Retrieving accent phrases

You can retrieve and inspect accent phrase information for a text:

GPU mode

In environments where a GPU is available, specify AccelerationMode::Gpu for faster synthesis:

Using multiple voice models

Load multiple .vvm files and switch between style IDs to use different character voices:
Last modified on May 17, 2026