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

# VOICEVOX Core for PHP

> Een pure PHP-pakket dat de dynamische C-bibliotheek van VOICEVOX CORE wrapt met PHP FFI. Gebruik tekst-naar-spraak (TTS) rechtstreeks vanuit PHP.

## Overzicht

[revolution/voicevox-core](https://github.com/invokable/voicevox-core-php) is een pure PHP-pakket dat de dynamische C-bibliotheek van [VOICEVOX CORE](https://github.com/VOICEVOX/voicevox_core) wrapt met PHP FFI.

VOICEVOX is een hoogwaardige Japanse tekst-naar-spraak-engine (TTS), en met dit pakket kun je rechtstreeks vanuit PHP spraak synthetiseren.

<Info>
  Wil je eerst de werking en beperkingen van PHP FFI zelf op een rij hebben, zie dan [PHP FFI](/nl/advanced/ffi).
</Info>

<Tip>
  Werk je vanuit een Laravel-app, lees dan ook [VOICEVOX for Laravel](/nl/packages/laravel-voicevox) — dan begrijp je ook meteen het verschil tussen de clientmodus en de native modus.
</Tip>

<Warning>
  Omdat PHP FFI in webserveromgevingen (zoals FPM) vaak is uitgeschakeld (`ffi.enable=false`), is dit pakket **bedoeld voor gebruik in een lokale CLI**.
</Warning>

## Vereisten

* PHP 8.3+
* De `ext-ffi`-extensie is ingeschakeld
* VOICEVOX CORE 0.16+

## Installatie

```bash theme={null}
composer require revolution/voicevox-core
```

## De bibliotheek opzetten

Om dit pakket te gebruiken heb je de dynamische bibliotheek van VOICEVOX CORE (`.so` / `.dylib`), de ONNX Runtime-bibliotheek en het OpenJTalk-woordenboek nodig.

<Steps>
  <Step title="Download voicevox_core">
    Download de downloader die past bij je OS en architectuur via [voicevox\_core releases](https://github.com/VOICEVOX/voicevox_core/releases) en voer die uit. Na uitvoering wordt in de huidige directory een `voicevox_core`-directory aangemaakt.

    De aangemaakte directorystructuur:

    ```
    voicevox_core/
    ├── dict/open_jtalk_dic_*/     # OpenJTalk-woordenboek
    ├── c_api/lib/                 # Dynamische bibliotheken (.so, .dylib)
    ├── models/vvms/               # Spraakmodelbestanden (.vvm)
    └── onnxruntime/               # ONNX Runtime-bibliotheek
    ```
  </Step>

  <Step title="Verplaats naar een permanente locatie">
    ```bash theme={null}
    mv voicevox_core ~/.local/voicevox_core
    ```
  </Step>

  <Step title="Maak een symbolische link (aanbevolen)">
    Maak een symbolische link zodat de bibliotheek automatisch wordt gevonden.

    <Warning>
      Gebruik voor `ln -s` altijd een **absoluut pad**.
    </Warning>

    **macOS:**

    ```bash theme={null}
    # Vervang [VOICEVOX_CORE_DIR] door het absolute pad van voicevox_core
    ln -s [VOICEVOX_CORE_DIR]/libvoicevox_core.dylib /usr/local/lib/libvoicevox_core.dylib
    ```

    Als het laden vanuit `/usr/local/lib/` niet lukt, stel dan `DYLD_FALLBACK_LIBRARY_PATH` in via bijvoorbeeld `.zshrc`:

    ```bash theme={null}
    export DYLD_FALLBACK_LIBRARY_PATH="$HOME/lib:/usr/local/lib:/usr/lib"
    ```

    **Linux:**

    ```bash theme={null}
    ln -s [VOICEVOX_CORE_DIR]/libvoicevox_core.so /usr/local/lib/libvoicevox_core.so
    ```
  </Step>
</Steps>

### Alternatief: opgeven via een omgevingsvariabele

Als je geen symbolische link kunt maken, stel dan het volledige pad naar het bibliotheekbestand in via de omgevingsvariabele `VOICEVOX_CORE_LIB_PATH`:

```bash theme={null}
export VOICEVOX_CORE_LIB_PATH=/path/to/libvoicevox_core.dylib
```

```bash theme={null}
export VOICEVOX_CORE_LIB_PATH="$HOME/.local/voicevox_core/c_api/lib/libvoicevox_core.dylib"
```

<Info>
  Als het laden op macOS ook met `DYLD_FALLBACK_LIBRARY_PATH` niet lukt, stel het dan in via `VOICEVOX_CORE_LIB_PATH`.
</Info>

## Documentatie

<Columns cols={2}>
  <Card title="Gebruik" href="/nl/packages/voicevox-core-php/usage" icon="play">
    Basisgebruik van tekst-naar-spraak en spraaksynthese, met codevoorbeelden.
  </Card>

  <Card title="API-referentie" href="/nl/packages/voicevox-core-php/api" icon="code">
    Gedetailleerde referentie van alle klassen, methodes en enums.
  </Card>
</Columns>

## Referentielinks

* GitHub: [invokable/voicevox-core-php](https://github.com/invokable/voicevox-core-php)
* VOICEVOX CORE: [VOICEVOX/voicevox\_core](https://github.com/VOICEVOX/voicevox_core)


## Related topics

- [VOICEVOX Core for PHP](/en/packages/voicevox-core-php/index.md)
