メインコンテンツへスキップ

エンジン API で歌わせる

エンジン API モードは、公式 VOICEVOX エンジン互換のソングエンドポイントも提供します。
エンジン API の基本セットアップは エンジン API: トーク を先に確認してください。

事前準備

歌声モデルを使うため、config/voicevox.phpcore.vvmss0.vvm が含まれていることを確認します(デフォルトで含まれます)。
VOICEVOX_CORE_PATH=/path/to/voicevox_core/

Laravel 版エンジンを起動する

php artisan serve --port=50513

歌声音声を生成する

1. sing_frame_audio_query を作成する

curl -s -X POST "http://127.0.0.1:50513/sing_frame_audio_query?speaker=6000" \
  -H "Content-Type: application/json" \
  -d '{
    "notes": [
      {"id": "a", "key": null, "frame_length": 15, "lyric": ""},
      {"id": "b", "key": 60, "frame_length": 94, "lyric": "ド"},
      {"id": "c", "key": 62, "frame_length": 94, "lyric": "レ"},
      {"id": "d", "key": 64, "frame_length": 187, "lyric": "ミ"},
      {"id": "e", "key": null, "frame_length": 2, "lyric": ""}
    ]
  }' \
  > frame_audio_query.json
speaker には sing または singing_teacher 種別のスタイル ID(例: 6000)を指定します。

2. frame_synthesis で音声合成する

curl -s -X POST "http://127.0.0.1:50513/frame_synthesis?speaker=3001" \
  -H "Content-Type: application/json" \
  -d @frame_audio_query.json \
  > song.wav
speaker には sing または frame_decode 種別のスタイル ID(例: 3001)を指定します。

Laravel クライアントから使う

Laravel 版エンジンに向けて Voicevox::song() を利用できます。
// config/voicevox.php
'client' => [
    'url' => env('VOICEVOX_URL', 'http://127.0.0.1:50513'),
],
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(480, 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, teacher: 6000)->generate(id: 3001);

$response->storeAs('engine', 'song.wav');

F0・ボリューム調整エンドポイント

curl -s -X POST "http://127.0.0.1:50513/sing_frame_f0?speaker=6000" \
  -H "Content-Type: application/json" \
  -d '{"score": {...}, "frame_audio_query": {...}}' \
  > f0.json

curl -s -X POST "http://127.0.0.1:50513/sing_frame_volume?speaker=6000" \
  -H "Content-Type: application/json" \
  -d '{"score": {...}, "frame_audio_query": {...}}' \
  > volume.json
F0 とボリュームを個別に更新する場合は、必ず F0 → ボリューム の順で実行してください。

ソング関連の対応状況

エンドポイントLaravel 版フォールバック備考
POST /sing_frame_audio_query
POST /frame_synthesis
POST /sing_frame_f0
POST /sing_frame_volumef0 → volume の順で更新
GET /singers
GET /singer_infoリソースインストールが必要

次に読むページ

Score と Note 詳細

Song API で使う Score / Note の詳細を確認します。

エンジン API: トーク

テキスト音声合成エンドポイントの使い方を確認します。

クライアント: ソング

同じ譜面を公式エンジンへ直接送るモードを確認します。
最終更新日 2026年5月23日