Vai al contenuto principale

Cantare tramite Engine API

La modalità Engine API fornisce anche endpoint per canzoni compatibili con il motore ufficiale VOICEVOX.
Per la configurazione di base dell’Engine API, consulta prima Engine API: Talk.

Prerequisiti

Per utilizzare il modello di canto, verifica che s0.vvm sia incluso in core.vvms di config/voicevox.php (è incluso per impostazione predefinita).
VOICEVOX_CORE_PATH=/path/to/voicevox_core/

Avvio della versione Laravel del motore

php artisan serve --port=50513

Generazione dell’audio cantato

1. Crea 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
In speaker specifica uno style ID di tipo sing o singing_teacher (es. 6000).

2. Sintetizza l’audio con 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
In speaker specifica uno style ID di tipo sing o frame_decode (es. 3001).

Utilizzo dal client Laravel

Puoi utilizzare Voicevox::song() verso la versione Laravel del motore.
// 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');

Endpoint di regolazione di F0 e 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
Quando aggiorni F0 e volume separatamente, eseguili sempre nell’ordine F0 → volume.

Stato del supporto per le canzoni

EndpointVersione LaravelFallbackNote
POST /sing_frame_audio_query
POST /frame_synthesis
POST /sing_frame_f0
POST /sing_frame_volumeAggiornamento nell’ordine f0 → volume
GET /singers
GET /singer_infoRichiede l’installazione delle risorse

Pagine successive

Dettagli su Score e Note

Verifica i dettagli su Score / Note usati nella Song API.

Engine API: Talk

Verifica l’utilizzo degli endpoint di sintesi vocale da testo.

Client: Song

Verifica la modalità che invia lo stesso spartito direttamente al motore ufficiale.
Ultima modifica il 13 luglio 2026