Download the PHP package revolution/voicevox-core without Composer

On this page you can find all versions of the php package revolution/voicevox-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package voicevox-core

VOICEVOX Core for PHP

tests integration tests linter Maintainability Code Coverage Ask DeepWiki

PHP FFI wrapper for VOICEVOX CORE — the text-to-speech engine library from the VOICEVOX project.

This is a package for pure PHP. For general use, the Laravel version is recommended.

Requirements

[!NOTE] PHP FFI is typically disabled in web server environments (e.g., FPM with ffi.enable=false). This library is intended for local CLI use only.

Installation

Library Setup (Linux / macOS)

This package requires the VOICEVOX CORE dynamic library (.so / .dylib), the ONNX Runtime library, and the OpenJTalk dictionary.

1. Download voicevox_core

Download the appropriate downloader for your OS and architecture from voicevox_core releases and run it. This creates a voicevox_core directory in the current directory containing:

2. Move to a permanent location

3. Create a symlink (Recommended)

Create a symlink so the library can be found automatically:

macOS:

If you cannot load from /usr/local/lib/, set DYLD_FALLBACK_LIBRARY_PATH in your .zshrc file or similar.

Linux:

[!WARNING] Always use absolute paths when using ln -s.

Alternative: Environment variable

If you cannot create a symlink, set the VOICEVOX_CORE_LIB_PATH environment variable to the full path of the library file:

Usage Example

The following talk.php demonstrates text-to-speech synthesis:

Run with:

Testing

API Reference

Onnxruntime

ONNX Runtime loader. A process-level singleton — only one instance exists per process.

Method Description
static loadOnce(string $filename = ''): self Load and initialize ONNX Runtime. On subsequent calls, ignores the argument and returns the existing instance.
static get(): ?self Return the existing instance, or null if not yet initialized.
supportedDevices(): string Return available device information as a JSON string.
static libRecommendedVersionedFilename(): string Return the recommended versioned filename of the ONNX Runtime library (e.g., libvoicevox_onnxruntime.1.23.2.dylib).
static libRecommendedUnversionedFilename(): string Return the recommended unversioned filename of the ONNX Runtime library.
static libMinRequiredMinorVersion(): int Return the minimum supported ONNX Runtime 1.x minor version.
static libMaxSupportedMinorVersion(): int Return the maximum supported ONNX Runtime 1.x minor version.

Constants:

Constant Description
LIB_MIN_REQUIRED_MINOR_VERSION Minimum supported ONNX Runtime 1.x minor version (17)
LIB_MAX_SUPPORTED_MINOR_VERSION Maximum supported ONNX Runtime 1.x minor version (29)
LIB_RECOMMENDED_NAME Recommended library base name (voicevox_onnxruntime)
LIB_RECOMMENDED_VERSION Recommended ONNX Runtime version (1.23.2)

OpenJtalk

Text analyzer using OpenJTalk.

Method Description
__construct(string $openJtalkDictDir) Initialize with the OpenJTalk dictionary directory path.
analyze(string $text): string Analyze Japanese text and return an accent phrase array as a JSON string.
useUserDict(UserDict $userDict): void Attach a user dictionary. Must be called again if the dictionary changes.

VoiceModelFile

Voice model file (.vvm file).

Method Description
static open(string $path): self Open a .vvm file.
id(): string Return the voice model ID as a hex string (16 bytes).
createMetasJson(): string Return speaker metadata as a JSON string.
close(): void Close the file and release resources.

Synthesizer

Main text-to-speech synthesizer.

Method Description
__construct(Onnxruntime $onnxruntime, OpenJtalk $openJtalk, AccelerationMode $accelerationMode = Auto, int $cpuNumThreads = 0) Initialize the synthesizer.
onnxruntime(): Onnxruntime Return the Onnxruntime instance held by this synthesizer.
isGpuMode(): bool Return whether GPU mode is active.
metas(): string Return loaded speaker metadata as a JSON string.
loadVoiceModel(VoiceModelFile $model, OnExistingVoiceModelId $onExisting = Error): void Load a voice model and choose the behavior for an already loaded model ID.
unloadVoiceModel(string $voiceModelId): void Unload a voice model by its hex ID.
isLoadedVoiceModel(string $voiceModelId): bool Check whether a voice model is loaded.
createAudioQuery(string $text, int $styleId): string Generate an AudioQuery JSON from Japanese text.
createAudioQueryFromKana(string $kana, int $styleId): string Generate an AudioQuery JSON from AquesTalk-style kana notation.
createAccentPhrases(string $text, int $styleId): string Generate an accent phrase array JSON from Japanese text.
createAccentPhrasesFromKana(string $kana, int $styleId): string Generate an accent phrase array JSON from kana notation.
replaceMoraData(string $accentPhrasesJson, int $styleId): string Return new accent phrases with updated mora pitch and phoneme length.
replacePhonemeLength(string $accentPhrasesJson, int $styleId): string Return new accent phrases with updated phoneme length.
replaceMoraPitch(string $accentPhrasesJson, int $styleId): string Return new accent phrases with updated mora pitch.
synthesis(string $audioQueryJson, int $styleId, bool $enableInterrogativeUpspeak = true): string Synthesize speech from an AudioQuery JSON. Returns WAV binary.
tts(string $text, int $styleId, bool $enableInterrogativeUpspeak = true): string Synthesize speech from Japanese text in one step. Returns WAV binary.
ttsFromKana(string $kana, int $styleId, bool $enableInterrogativeUpspeak = true): string Synthesize speech from kana notation. Returns WAV binary.
createSingFrameAudioQuery(string $scoreJson, int $styleId): string Generate a singing synthesis query JSON from a musical score.
frameSynthesis(string $frameAudioQueryJson, int $styleId): string Synthesize singing audio from a frame audio query. Returns WAV binary.
createSingFrameF0(string $scoreJson, string $frameAudioQueryJson, int $styleId): string Generate per-frame F0 (fundamental frequency) values as a JSON float array.
createSingFrameVolume(string $scoreJson, string $frameAudioQueryJson, int $styleId): string Generate per-frame volume values as a JSON float array.

VoicevoxCore

Global utility functions for VOICEVOX Core.

Method Description
getVersion(): string Return the VOICEVOX Core version as a SemVer string.
audioQueryCreateFromAccentPhrases(string $accentPhrasesJson): string Generate an AudioQuery JSON from an accent phrase array JSON.
audioQueryValidate(string $audioQueryJson): void Validate an AudioQuery JSON. Throws VoicevoxException if invalid.
accentPhraseValidate(string $accentPhraseJson): void Validate an AccentPhrase JSON. Throws VoicevoxException if invalid.
moraValidate(string $moraJson): void Validate a Mora JSON. Throws VoicevoxException if invalid.
scoreValidate(string $scoreJson): void Validate a Score JSON. Throws VoicevoxException if invalid.
noteValidate(string $noteJson): void Validate a Note JSON. Throws VoicevoxException if invalid.
frameAudioQueryValidate(string $frameAudioQueryJson): void Validate a FrameAudioQuery JSON. Throws VoicevoxException if invalid.
framePhonemeValidate(string $framePhonemeJson): void Validate a FramePhoneme JSON. Throws VoicevoxException if invalid.
ensureCompatible(string $scoreJson, string $frameAudioQueryJson): void Check that a score and frame audio query are compatible. Throws VoicevoxException if not.

UserDict

User dictionary for custom word pronunciation.

Method Description
__construct() Create a new empty user dictionary.
load(string $path): void Load a user dictionary from a file.
save(string $path): void Save the user dictionary to a file.
addWord(string $surface, string $pronunciation, int $accentType, UserDictWordType $wordType = CommonNoun, int $priority = 5): string Add a word. Returns the word UUID as a hex string.
updateWord(string $wordUuid, string $surface, string $pronunciation, int $accentType, UserDictWordType $wordType = CommonNoun, int $priority = 5): void Update an existing word by UUID.
removeWord(string $wordUuid): void Remove a word by UUID.
importDict(UserDict $other): void Import words from another UserDict.
toJson(): string Return all words as a JSON string.

AccelerationMode (enum)

Hardware acceleration mode for the synthesizer.

Case Value Description
Auto 0 Automatically select the best available mode.
Cpu 1 Force CPU mode.
Gpu 2 Force GPU mode.

UserDictWordType (enum)

Word type for user dictionary entries.

Case Value Description
ProperNoun 0 Proper noun
CommonNoun 1 Common noun
Verb 2 Verb
Adjective 3 Adjective
Suffix 4 Suffix

VoicevoxException

Thrown when a VOICEVOX Core C API call returns an error code. The exception message contains the error description from the library.

License

MIT


All versions of voicevox-core with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-ffi Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package revolution/voicevox-core contains the following files

Loading the files please wait ...