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

> A pure PHP package that wraps VOICEVOX CORE's C dynamic library via PHP FFI. Use text-to-speech (TTS) directly from PHP.

## Overview

[revolution/voicevox-core](https://github.com/invokable/voicevox-core-php) is a pure PHP package that wraps [VOICEVOX CORE](https://github.com/VOICEVOX/voicevox_core)'s C dynamic library via PHP FFI.

VOICEVOX is a high-quality Japanese text-to-speech (TTS) engine, and this package lets you perform synthesis directly from PHP.

> [!NOTE]
>
> If you want to first review how PHP FFI works and its limitations, see [PHP FFI](https://kawax.biz/en/advanced/ffi.md).

> [!TIP]
>
> If you're working from a Laravel app, also read [VOICEVOX for Laravel](https://kawax.biz/en/packages/laravel-voicevox.md) to compare the client and native modes.

> [!WARNING]
>
> PHP FFI is often disabled (`ffi.enable=false`) in web server environments such as FPM, so this package assumes **use from a local CLI**.

## Requirements

* PHP 8.3+
* `ext-ffi` enabled
* VOICEVOX CORE 0.17.1+

## Installation

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

## Library setup

To use this package, you need the VOICEVOX CORE dynamic library (`.so` / `.dylib`), the ONNX Runtime library, and the OpenJTalk dictionary.

**1. Download voicevox\_core**

Download the downloader that matches your OS and architecture from the [voicevox\_core releases](https://github.com/VOICEVOX/voicevox_core/releases) and run it. A `voicevox_core` directory is created in the current directory.

The generated directory structure:

```
voicevox_core/
├── dict/open_jtalk_dic_*/     # OpenJTalk dictionary
├── c_api/lib/                 # Dynamic library (.so, .dylib)
├── models/vvms/               # Voice model files (.vvm)
└── onnxruntime/               # ONNX Runtime library
```

**2. Move it to a permanent location**

```bash theme={null}
mv voicevox_core ~/.local/voicevox_core
```

**3. Create a symlink (recommended)**

Create a symlink so the library can be located automatically.

> [!WARNING]
>
> Always use an **absolute path** with `ln -s`.

**macOS:**

```bash theme={null}
# Replace [VOICEVOX_CORE_DIR] with the absolute path to voicevox_core
ln -s [VOICEVOX_CORE_DIR]/libvoicevox_core.dylib /usr/local/lib/libvoicevox_core.dylib
```

If loading from `/usr/local/lib/` fails, set `DYLD_FALLBACK_LIBRARY_PATH` in `.zshrc` or similar:

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

### Alternative: specifying via environment variable

If you can't create a symlink, set the full path to the library file in the `VOICEVOX_CORE_LIB_PATH` environment variable:

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

> [!NOTE]
>
> On macOS, if loading still fails even with `DYLD_FALLBACK_LIBRARY_PATH`, set `VOICEVOX_CORE_LIB_PATH` instead.

## Documentation

> [card] [Usage](https://kawax.biz/en/packages/voicevox-core-php/usage.md)
>
> Basic usage and code samples for text-to-speech and audio synthesis.

> [card] [API reference](https://kawax.biz/en/packages/voicevox-core-php/api.md)
>
> Detailed reference for every class, method, and enum.

## Reference links

* 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

- [Usage - VOICEVOX Core for PHP](https://kawax.biz/en/packages/voicevox-core-php/usage.md)
- [API Reference - VOICEVOX Core for PHP](https://kawax.biz/en/packages/voicevox-core-php/api.md)
- [VOICEVOX for Laravel](https://kawax.biz/en/packages/laravel-voicevox/index.md)
- [PHP FFI](https://kawax.biz/en/advanced/ffi.md)
- [Installation and setup - VOICEVOX for Laravel](https://kawax.biz/en/packages/laravel-voicevox/installation.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.