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

# Modo cliente: Song (síntesis de voz cantada) - VOICEVOX for Laravel

> Explica cómo sintetizar voz cantada a partir de Score y Note en modo cliente de VOICEVOX for Laravel.

## Cantar en modo cliente

En la síntesis de voz cantada del modo cliente se usan las APIs `sing_frame_audio_query` y `frame_synthesis` del motor oficial de VOICEVOX.

A diferencia de Talk, hay que construir primero un `Score` y sus `Note`.

## Preparación

```shell theme={null}
docker pull voicevox/voicevox_engine:cpu-latest
docker run --rm -p '127.0.0.1:50021:50021' voicevox/voicevox_engine:cpu-latest
```

## Crear `Score` y `Note`

```php theme={null}
use Revolution\Voicevox\Song\Note;
use Revolution\Voicevox\Song\Score;

$score = Score::make([
    Note::make(length: 15),
    Note::make(length: Note::len(ticks: 480, bpm: 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),
]);
```

| Parámetro | Tipo        | Descripción                                   |
| --------- | ----------- | --------------------------------------------- |
| `length`  | `int`       | Longitud en frames                            |
| `lyric`   | `string`    | Letra. Cadena vacía u omitida indica silencio |
| `key`     | `int\|null` | Número de nota MIDI                           |

<Tip>
  Con `Note::len($ticks, $bpm)` puedes calcular la longitud en frames a partir de los ticks MIDI y el BPM. Es fácil si tratas la negra como 480 ticks.
</Tip>

## Uso básico

```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('client', 'song.wav');
```

### `teacher` e `id`

* `teacher`: style ID que se pasa a `sing_frame_audio_query`. Actualmente solo existe el 6000, así que 6000 es el valor por defecto.
* `generate(id:)`: style ID que se pasa a `frame_synthesis`.

Puedes obtener la lista de speakers de voz cantada disponibles con `singers()`.

```php theme={null}
use Revolution\Voicevox\Voicevox;

$singers = Voicevox::singers();
```

## Ajustar F0 y volumen con `tap()`

En Song el uso de `tap()` es especialmente claro: puedes ajustar el `SongAudioQuery` antes de pasarlo a `generate()`.

```php theme={null}
use Revolution\Voicevox\Client\SongAudioQuery;
use Revolution\Voicevox\Voicevox;

$response = Voicevox::song($score, teacher: 6000)
    ->tap(function (SongAudioQuery $song) {
        $song->sync();
    })
    ->generate(id: 3001);
```

Para actualizar F0 y volumen por separado, hazlo en el orden **F0 → volumen**.

```php theme={null}
->tap(function (SongAudioQuery $song) {
    $song->updateF0();
    $song->updateVolume();
})
```

`tap()` también es útil cuando quieres modificar el Score y volver a sincronizar.

```php theme={null}
->tap(function (SongAudioQuery $song) {
    $song->score->notes[2] = Note::make(length: Note::len(480, 120), lyric: 'ファ', key: 65);
    $song->sync();
})
```

<Info>
  El planteamiento de `tap()` está recogido en [Helper tap() y trait Tappable](/es/advanced/tap). VOICEVOX for Laravel es un ejemplo típico de «quiero ajustar solo el objeto intermedio sin cambiar el valor de retorno».
</Info>

## Siguientes páginas

<Columns cols={3}>
  <Card title="Detalle de Score y Note" href="/es/packages/laravel-voicevox/song-score-note" icon="list-music">
    Consulta el cálculo de longitudes de frame y el patrón de gestión en JSON.
  </Card>

  <Card title="Song nativo" href="/es/packages/laravel-voicevox/native-song" icon="music">
    Usa el mismo `Score` en modo nativo vía FFI.
  </Card>

  <Card title="Uso de VOICEVOX Core for PHP" href="/es/packages/voicevox-core-php/usage" icon="library">
    Consulta el flujo de síntesis con la biblioteca central por sí sola.
  </Card>
</Columns>


## Related topics

- [Modo nativo: Song (síntesis de voz cantada) - VOICEVOX for Laravel](/es/packages/laravel-voicevox/native-song.md)
- [Modo Engine API: Song (síntesis de voz cantada) - VOICEVOX for Laravel](/es/packages/laravel-voicevox/engine-song.md)
- [Modo cliente: Talk (síntesis de voz desde texto) - VOICEVOX for Laravel](/es/packages/laravel-voicevox/client-talk.md)
- [Modo nativo: Talk (síntesis de voz desde texto) - VOICEVOX for Laravel](/es/packages/laravel-voicevox/native-talk.md)
- [Modo Engine API: Talk (síntesis de voz desde texto) - VOICEVOX for Laravel](/es/packages/laravel-voicevox/engine-talk.md)
