Passer au contenu principal
VOICEVOX for Laravel est un package pour utiliser les fonctionnalités de synthèse vocale de VOICEVOX depuis Laravel. Il permet de générer de la voix en japonais à partir de texte.
Commencer par le mode client offre la mise en place la plus rapide. Dans un environnement où FFI est disponible, vous pourrez ensuite migrer progressivement vers le mode natif ou le mode API du moteur.

Trois modes d’utilisation

ModeMode d’exécutionFFICas d’usageGuide
Mode clientConnexion HTTP au moteur officiel VOICEVOXNon requisPremier essai, environnement Docker, environnement sans FFIClient Talk / Client Song
Mode natifAppel direct de VOICEVOX CORE via PHP FFIRequisPerformance, exécution hors ligne, intégration à des outils CLINative Talk / Native Song
Mode API du moteurLaravel expose une API compatible VOICEVOXRequisExposition d’une API, intégration multi-clientsEngine Talk / Engine Song

Démarrage rapide

Procédure en mode client.
1

Installer le package

composer require revolution/laravel-voicevox
Pour les détails, consultez Installation et configuration.
2

Démarrer le moteur officiel

docker pull voicevox/voicevox_engine:cpu-latest
docker run --rm -p '127.0.0.1:50021:50021' voicevox/voicevox_engine:cpu-latest
3

Essayer la synthèse vocale

use Revolution\Voicevox\Voicevox;

$response = Voicevox::talk('こんにちは、Laravel です。', id: 1)->generate(id: 1);
$response->storeAs('output.wav');

Fonctionnalités principales

Synthèse vocale (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);

Synthèse chantée (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);

Dictionnaire utilisateur et presets

En mode client, utilisez la Facade Voicevox pour manipuler le dictionnaire utilisateur et les presets côté moteur officiel.
use Revolution\Voicevox\Voicevox;

$uuid = Voicevox::addWord(
    surface: 'Laravel',
    pronunciation: 'ララベル',
    accentType: 3,
);

$presetId = Voicevox::addPreset([
    'id' => 0,
    'name' => 'ゆっくり丁寧',
    '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,
]);

Intégration Laravel AI SDK

use Laravel\Ai\Audio;

$audio = Audio::of('こんにちは、Laravel です。')
    ->voice('ずんだもん')
    ->generate();

$audio->storeAs('output.wav');

Prochaines étapes

Dernière modification le 13 juillet 2026