Passer au contenu principal

Faire chanter via l’API du moteur

Le mode API du moteur fournit également les endpoints Song compatibles avec le moteur officiel VOICEVOX.
Pour la mise en place de base de l’API du moteur, consultez d’abord API du moteur : Talk.

Prérequis

Pour utiliser le modèle de chant, vérifiez que s0.vvm figure bien dans core.vvms de config/voicevox.php (il y est par défaut).
VOICEVOX_CORE_PATH=/path/to/voicevox_core/

Démarrer le moteur version Laravel

php artisan serve --port=50513

Générer la voix chantée

1. Créer un 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 doit être un ID de style de type sing ou singing_teacher (par exemple 6000).

2. Synthétiser via 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 doit être un ID de style de type sing ou frame_decode (par exemple 3001).

Utilisation depuis un client Laravel

Vous pouvez utiliser Voicevox::song() en pointant vers le moteur version Laravel.
// 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');

Endpoints d’ajustement F0 et volume

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
Pour mettre à jour F0 et volume individuellement, exécutez impérativement dans l’ordre F0 → volume.

État de la prise en charge côté Song

EndpointVersion LaravelFallbackRemarque
POST /sing_frame_audio_query
POST /frame_synthesis
POST /sing_frame_f0
POST /sing_frame_volumeMise à jour dans l’ordre f0 → volume
GET /singers
GET /singer_infoL’installation des ressources est nécessaire

Pages suivantes

Détails Score et Note

Découvrez les détails de Score / Note utilisés par l’API Song.

API du moteur : Talk

Découvrez l’utilisation des endpoints de synthèse vocale de texte.

Client : Song

Découvrez le mode où l’on envoie la même partition directement au moteur officiel.
Dernière modification le 13 juillet 2026