VOICEVOX for Laravel brings VOICEVOX speech synthesis features into Laravel. You can generate natural Japanese voice output from text.
Start with client mode for the fastest setup. If your environment supports FFI, you can move to native mode or engine API mode later.
Three usage modes
| Mode | Runtime | FFI | Best for | Guide |
|---|
| Client mode | HTTP connection to official VOICEVOX engine | Not required | First trial, Docker environments, environments without FFI | Client Talk / Client Song |
| Native mode | Direct VOICEVOX CORE calls through PHP FFI | Required | Better performance, offline use, CLI integration | Native Talk / Native Song |
| Engine API mode | Laravel serves VOICEVOX-compatible API endpoints | Required | Publishing as an API server, multi-client integration | Engine Talk / Engine Song |
Quick start
These steps cover client mode.
Start the official engine
docker pull voicevox/voicevox_engine:cpu-latest
docker run --rm -p '127.0.0.1:50021:50021' voicevox/voicevox_engine:cpu-latest
Try speech synthesis
use Revolution\Voicevox\Voicevox;
$response = Voicevox::talk('こんにちは、Laravel です。', id: 1)->generate(id: 1);
$response->storeAs('output.wav');
Core features
Speech synthesis (Talk)
use Revolution\Voicevox\Client\TalkAudioQuery;
use Revolution\Voicevox\Voicevox;
$response = Voicevox::talk('こんにちは', id: 1)
->tap(function (TalkAudioQuery $talk) {
$talk->audioQuery['speedScale'] = 1.2;
$talk->audioQuery['pitchScale'] = 0.05;
$talk->audioQuery['intonationScale'] = 1.5;
$talk->audioQuery['volumeScale'] = 1.0;
})
->generate(id: 1);
Singing synthesis (Song)
use Revolution\Voicevox\Song\Note;
use Revolution\Voicevox\Song\Score;
use Revolution\Voicevox\Voicevox;
$score = Score::make([
Note::make(length: 15),
Note::make(length: Note::len(ticks: 480, bpm: 120), lyric: 'ド', key: 60),
Note::make(length: Note::len(480, 120), lyric: 'レ', key: 62),
Note::make(length: Note::len(960, 120), lyric: 'ミ', key: 64),
Note::make(length: 2),
]);
$response = Voicevox::song($score)->generate(id: 3001);
User dictionary and presets
In client mode, use the Voicevox facade to manage the user dictionary and presets on the official engine side.
use Revolution\Voicevox\Voicevox;
$uuid = Voicevox::addWord(
surface: 'Laravel',
pronunciation: 'ララベル',
accentType: 3,
);
$presetId = Voicevox::addPreset([
'id' => 0,
'name' => 'Slow and clear',
'speaker_uuid' => '7ffcb7ce-00ec-4bdc-82cd-45a8889e43ff',
'style_id' => 1,
'speedScale' => 0.8,
'pitchScale' => 0.0,
'intonationScale' => 1.2,
'volumeScale' => 1.0,
'prePhonemeLength' => 0.1,
'postPhonemeLength' => 0.1,
]);
Laravel AI SDK integration
use Laravel\Ai\Audio;
$audio = Audio::of('こんにちは、Laravel です。')
->voice('ずんだもん')
->generate();
$audio->storeAs('output.wav');
Next steps