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

# Mode API du moteur : Song (synthèse vocale chantée) - VOICEVOX for Laravel

> Procédure pour utiliser les endpoints de synthèse chantée via l'API compatible moteur VOICEVOX dans une application Laravel.

## Faire chanter via l'API du moteur

Le mode API du moteur fournit également les endpoints Song compatibles avec le moteur officiel VOICEVOX.

<Info>
  Pour la mise en place de base de l'API du moteur, consultez d'abord [API du moteur : Talk](/fr/packages/laravel-voicevox/engine-talk).
</Info>

## 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).

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

## Démarrer le moteur version Laravel

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

## Générer la voix chantée

### 1. Créer un `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
```

`speaker` doit être un ID de style de type `sing` ou `singing_teacher` (par exemple 6000).

### 2. Synthétiser via `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
```

`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.

```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');
```

## Endpoints d'ajustement F0 et 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>
  Pour mettre à jour F0 et volume individuellement, exécutez impérativement dans l'ordre **F0 → volume**.
</Warning>

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

| Endpoint                       | Version Laravel | Fallback | Remarque                                     |
| ------------------------------ | --------------- | -------- | -------------------------------------------- |
| `POST /sing_frame_audio_query` | ✅               | ✅        |                                              |
| `POST /frame_synthesis`        | ✅               | ✅        |                                              |
| `POST /sing_frame_f0`          | ✅               | ✅        |                                              |
| `POST /sing_frame_volume`      | ✅               | ✅        | Mise à jour dans l'ordre f0 → volume         |
| `GET /singers`                 | ✅               | ✅        |                                              |
| `GET /singer_info`             | ✅               | ✅        | L'installation des ressources est nécessaire |

## Pages suivantes

<Columns cols={3}>
  <Card title="Détails Score et Note" href="/fr/packages/laravel-voicevox/song-score-note" icon="list-music">
    Découvrez les détails de `Score` / `Note` utilisés par l'API Song.
  </Card>

  <Card title="API du moteur : Talk" href="/fr/packages/laravel-voicevox/engine-talk" icon="message-circle">
    Découvrez l'utilisation des endpoints de synthèse vocale de texte.
  </Card>

  <Card title="Client : Song" href="/fr/packages/laravel-voicevox/client-song" icon="music">
    Découvrez le mode où l'on envoie la même partition directement au moteur officiel.
  </Card>
</Columns>


## Related topics

- [Mode client : Song (synthèse vocale chantée) - VOICEVOX for Laravel](/fr/packages/laravel-voicevox/client-song.md)
- [Mode natif : Song (synthèse vocale chantée) - VOICEVOX for Laravel](/fr/packages/laravel-voicevox/native-song.md)
- [Mode API du moteur : Talk (synthèse vocale de texte) - VOICEVOX for Laravel](/fr/packages/laravel-voicevox/engine-talk.md)
- [VOICEVOX for Laravel](/fr/packages/laravel-voicevox/index.md)
- [Installation et configuration - VOICEVOX for Laravel](/fr/packages/laravel-voicevox/installation.md)
