> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Modalità Engine API: Song (sintesi vocale cantata) - VOICEVOX for Laravel

> Procedura per utilizzare gli endpoint di sintesi vocale cantata dell'API compatibile con il motore VOICEVOX all'interno di un'app Laravel.

## Cantare tramite Engine API

La modalità Engine API fornisce anche endpoint per canzoni compatibili con il motore ufficiale VOICEVOX.

<Info>
  Per la configurazione di base dell'Engine API, consulta prima [Engine API: Talk](/it/packages/laravel-voicevox/engine-talk).
</Info>

## Prerequisiti

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

```dotenv theme={null}
VOICEVOX_CORE_PATH=/path/to/voicevox_core/
```

## Avvio della versione Laravel del motore

```shell theme={null}
php artisan serve --port=50513
```

## Generazione dell'audio cantato

### 1. Crea `sing_frame_audio_query`

```shell theme={null}
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`

```shell theme={null}
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.

```php theme={null}
// config/voicevox.php
'client' => [
    'url' => env('VOICEVOX_URL', 'http://127.0.0.1:50513'),
],
```

```php theme={null}
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

```shell theme={null}
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
```

<Warning>
  Quando aggiorni F0 e volume separatamente, eseguili sempre nell'ordine **F0 → volume**.
</Warning>

## Stato del supporto per le canzoni

| Endpoint                       | Versione Laravel | Fallback | Note                                   |
| ------------------------------ | ---------------- | -------- | -------------------------------------- |
| `POST /sing_frame_audio_query` | ✅                | ✅        |                                        |
| `POST /frame_synthesis`        | ✅                | ✅        |                                        |
| `POST /sing_frame_f0`          | ✅                | ✅        |                                        |
| `POST /sing_frame_volume`      | ✅                | ✅        | Aggiornamento nell'ordine f0 → volume  |
| `GET /singers`                 | ✅                | ✅        |                                        |
| `GET /singer_info`             | ✅                | ✅        | Richiede l'installazione delle risorse |

## Pagine successive

<Columns cols={3}>
  <Card title="Dettagli su Score e Note" href="/it/packages/laravel-voicevox/song-score-note" icon="list-music">
    Verifica i dettagli su `Score` / `Note` usati nella Song API.
  </Card>

  <Card title="Engine API: Talk" href="/it/packages/laravel-voicevox/engine-talk" icon="message-circle">
    Verifica l'utilizzo degli endpoint di sintesi vocale da testo.
  </Card>

  <Card title="Client: Song" href="/it/packages/laravel-voicevox/client-song" icon="music">
    Verifica la modalità che invia lo stesso spartito direttamente al motore ufficiale.
  </Card>
</Columns>


## Related topics

- [Modalità client: Song (sintesi vocale cantata) - VOICEVOX for Laravel](/it/packages/laravel-voicevox/client-song.md)
- [Modalità nativa: Song (sintesi vocale canora) - VOICEVOX for Laravel](/it/packages/laravel-voicevox/native-song.md)
- [Modalità API Engine: Talk (sintesi vocale da testo) - VOICEVOX for Laravel](/it/packages/laravel-voicevox/engine-talk.md)
- [Modalità nativa: Talk (sintesi vocale da testo) - VOICEVOX for Laravel](/it/packages/laravel-voicevox/native-talk.md)
- [Modalità client: Talk (sintesi vocale da testo) - VOICEVOX for Laravel](/it/packages/laravel-voicevox/client-talk.md)
