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

# API-referentie - VOICEVOX Core for PHP

> Referentie van alle klassen, methodes en enums van VOICEVOX Core for PHP.

## `Onnxruntime`

De ONNX Runtime-loader. Een singleton op procesniveau: er bestaat maar één instantie per proces.

### Methodes

| Methode                                        | Beschrijving                                                                                                                                       |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `static loadOnce(string $filename = ''): self` | Laadt en initialiseert ONNX Runtime. Bij een tweede en volgende aanroep wordt het argument genegeerd en wordt de bestaande instantie teruggegeven. |
| `static get(): ?self`                          | Geeft de bestaande instantie terug. Geeft `null` terug als er nog niet is geïnitialiseerd.                                                         |
| `supportedDevices(): string`                   | Geeft informatie over de beschikbare apparaten terug als JSON-string.                                                                              |
| `static libVersionedFilename(): string`        | Geeft de bestandsnaam van de ONNX Runtime-bibliotheek mét versie terug (bijvoorbeeld `libvoicevox_onnxruntime.1.17.3.dylib`).                      |
| `static libUnversionedFilename(): string`      | Geeft de bestandsnaam van de ONNX Runtime-bibliotheek zónder versie terug.                                                                         |

### Constanten

| Constante     | Beschrijving                                          |
| ------------- | ----------------------------------------------------- |
| `LIB_NAME`    | Basisnaam van de bibliotheek (`voicevox_onnxruntime`) |
| `LIB_VERSION` | Aanbevolen ONNX Runtime-versie                        |

***

## `OpenJtalk`

Tekstanalysator op basis van OpenJTalk.

### Methodes

| Methode                                 | Beschrijving                                                                                                |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `__construct(string $openJtalkDictDir)` | Initialiseert met het pad naar de OpenJTalk-woordenboekdirectory.                                           |
| `analyze(string $text): string`         | Analyseert Japanse tekst en geeft JSON van een array van accentfrases terug.                                |
| `useUserDict(UserDict $userDict): void` | Past een gebruikerswoordenboek toe. Bij wijzigingen in het woordenboek moet dit opnieuw worden aangeroepen. |

***

## `VoiceModelFile`

Spraakmodelbestand (`.vvm`-bestand).

### Methodes

| Methode                           | Beschrijving                                              |
| --------------------------------- | --------------------------------------------------------- |
| `static open(string $path): self` | Opent een `.vvm`-bestand.                                 |
| `id(): string`                    | Geeft het spraakmodel-ID terug als hex-string (16 bytes). |
| `createMetasJson(): string`       | Geeft de spreker-metadata terug als JSON-string.          |
| `close(): void`                   | Sluit het bestand en geeft de resources vrij.             |

***

## `Synthesizer`

De hoofdklasse voor tekst-naar-spraak.

### Methodes

| Methode                                                                                                                          | Beschrijving                                                                                            |
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `__construct(Onnxruntime $onnxruntime, OpenJtalk $openJtalk, AccelerationMode $accelerationMode = Auto, int $cpuNumThreads = 0)` | Initialiseert de synthesizer.                                                                           |
| `onnxruntime(): Onnxruntime`                                                                                                     | Geeft de `Onnxruntime`-instantie terug die deze synthesizer bevat.                                      |
| `isGpuMode(): bool`                                                                                                              | Geeft terug of de GPU-modus actief is.                                                                  |
| `metas(): string`                                                                                                                | Geeft de metadata van de geladen sprekers terug als JSON-string.                                        |
| `loadVoiceModel(VoiceModelFile $model): void`                                                                                    | Laadt een spraakmodel.                                                                                  |
| `unloadVoiceModel(string $voiceModelId): void`                                                                                   | Ontlaadt het spraakmodel dat is opgegeven met een hex-ID.                                               |
| `isLoadedVoiceModel(string $voiceModelId): bool`                                                                                 | Controleert of een spraakmodel geladen is.                                                              |
| `createAudioQuery(string $text, int $styleId): string`                                                                           | Genereert AudioQuery-JSON uit Japanse tekst.                                                            |
| `createAudioQueryFromKana(string $kana, int $styleId): string`                                                                   | Genereert AudioQuery-JSON uit kana-notatie in AquesTalk-stijl.                                          |
| `createAccentPhrases(string $text, int $styleId): string`                                                                        | Genereert JSON van een array van accentfrases uit Japanse tekst.                                        |
| `createAccentPhrasesFromKana(string $kana, int $styleId): string`                                                                | Genereert JSON van een array van accentfrases uit kana-notatie.                                         |
| `replaceMoraData(string $accentPhrasesJson, int $styleId): string`                                                               | Geeft nieuwe accentfrases terug met bijgewerkte mora-toonhoogte en foneemlengte.                        |
| `replacePhonemeLength(string $accentPhrasesJson, int $styleId): string`                                                          | Geeft nieuwe accentfrases terug met bijgewerkte foneemlengte.                                           |
| `replaceMoraPitch(string $accentPhrasesJson, int $styleId): string`                                                              | Geeft nieuwe accentfrases terug met bijgewerkte mora-toonhoogte.                                        |
| `synthesis(string $audioQueryJson, int $styleId, bool $enableInterrogativeUpspeak = true): string`                               | Synthetiseert spraak uit AudioQuery-JSON. Geeft een WAV-binary terug.                                   |
| `tts(string $text, int $styleId, bool $enableInterrogativeUpspeak = true): string`                                               | Synthetiseert spraak in één stap uit Japanse tekst. Geeft een WAV-binary terug.                         |
| `ttsFromKana(string $kana, int $styleId, bool $enableInterrogativeUpspeak = true): string`                                       | Synthetiseert spraak uit kana-notatie. Geeft een WAV-binary terug.                                      |
| `createSingFrameAudioQuery(string $scoreJson, int $styleId): string`                                                             | Genereert JSON van een zangsynthesequery uit partituur-JSON.                                            |
| `frameSynthesis(string $frameAudioQueryJson, int $styleId): string`                                                              | Synthetiseert zang uit een frame-audioquery. Geeft een WAV-binary terug.                                |
| `createSingFrameF0(string $scoreJson, string $frameAudioQueryJson, int $styleId): string`                                        | Geeft uit een partituur en zangquery de F0 (grondfrequentie) per frame terug als JSON-array van floats. |
| `createSingFrameVolume(string $scoreJson, string $frameAudioQueryJson, int $styleId): string`                                    | Geeft uit een partituur en zangquery het volume per frame terug als JSON-array van floats.              |

***

## `VoicevoxCore`

Globale hulpfuncties van VOICEVOX Core.

### Methodes

| Methode                                                                         | Beschrijving                                                                                                                   |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `static getVersion(): string`                                                   | Geeft de versie van VOICEVOX Core terug als SemVer-string.                                                                     |
| `static audioQueryCreateFromAccentPhrases(string $accentPhrasesJson): string`   | Genereert AudioQuery-JSON uit JSON van een array van accentfrases.                                                             |
| `static audioQueryValidate(string $audioQueryJson): void`                       | Valideert `AudioQuery`-JSON. Gooit een `VoicevoxException` bij ongeldige invoer.                                               |
| `static accentPhraseValidate(string $accentPhraseJson): void`                   | Valideert `AccentPhrase`-JSON. Gooit een `VoicevoxException` bij ongeldige invoer.                                             |
| `static moraValidate(string $moraJson): void`                                   | Valideert `Mora`-JSON. Gooit een `VoicevoxException` bij ongeldige invoer.                                                     |
| `static scoreValidate(string $scoreJson): void`                                 | Valideert `Score`-JSON. Gooit een `VoicevoxException` bij ongeldige invoer.                                                    |
| `static noteValidate(string $noteJson): void`                                   | Valideert `Note`-JSON. Gooit een `VoicevoxException` bij ongeldige invoer.                                                     |
| `static frameAudioQueryValidate(string $frameAudioQueryJson): void`             | Valideert `FrameAudioQuery`-JSON. Gooit een `VoicevoxException` bij ongeldige invoer.                                          |
| `static framePhonemeValidate(string $framePhonemeJson): void`                   | Valideert `FramePhoneme`-JSON. Gooit een `VoicevoxException` bij ongeldige invoer.                                             |
| `static ensureCompatible(string $scoreJson, string $frameAudioQueryJson): void` | Controleert of de combinatie van partituur en zangsynthesequery geldig is. Gooit een `VoicevoxException` bij ongeldige invoer. |

***

## `UserDict`

Gebruikerswoordenboek voor het registreren van de uitspraak van eigen woorden.

### Methodes

| Methode                                                                                                                                                   | Beschrijving                                                   |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| `__construct()`                                                                                                                                           | Maakt een leeg gebruikerswoordenboek aan.                      |
| `load(string $path): void`                                                                                                                                | Laadt een gebruikerswoordenboek uit een bestand.               |
| `save(string $path): void`                                                                                                                                | Slaat het gebruikerswoordenboek op in een bestand.             |
| `addWord(string $surface, string $pronunciation, int $accentType, UserDictWordType $wordType = CommonNoun, int $priority = 5): string`                    | Voegt een woord toe. Geeft de woord-UUID terug als hex-string. |
| `updateWord(string $wordUuid, string $surface, string $pronunciation, int $accentType, UserDictWordType $wordType = CommonNoun, int $priority = 5): void` | Werkt een bestaand woord bij, opgegeven met een UUID.          |
| `removeWord(string $wordUuid): void`                                                                                                                      | Verwijdert het woord dat is opgegeven met een UUID.            |
| `importDict(UserDict $other): void`                                                                                                                       | Importeert woorden uit een andere `UserDict`.                  |
| `toJson(): string`                                                                                                                                        | Geeft alle woorden terug als JSON-string.                      |

***

## Enum: `AccelerationMode`

De hardwareversnellingsmodus van de synthesizer.

| Case   | Waarde | Beschrijving                                 |
| ------ | ------ | -------------------------------------------- |
| `Auto` | `0`    | Kiest automatisch de best beschikbare modus. |
| `Cpu`  | `1`    | Forceert de CPU-modus.                       |
| `Gpu`  | `2`    | Forceert de GPU-modus.                       |

***

## Enum: `UserDictWordType`

De woordsoort van een gebruikerswoordenboek-item.

| Case         | Waarde | Beschrijving                 |
| ------------ | ------ | ---------------------------- |
| `ProperNoun` | `0`    | Eigennaam                    |
| `CommonNoun` | `1`    | Gewoon zelfstandig naamwoord |
| `Verb`       | `2`    | Werkwoord                    |
| `Adjective`  | `3`    | Bijvoeglijk naamwoord        |
| `Suffix`     | `4`    | Achtervoegsel                |

***

## `VoicevoxException`

Wordt gegooid wanneer een C API-aanroep van VOICEVOX Core een foutcode teruggeeft. Het exceptionbericht bevat de foutbeschrijving van de bibliotheek.


## Related topics

- [VOICEVOX Core for PHP](/nl/packages/voicevox-core-php/index.md)
- [Gebruik - VOICEVOX Core for PHP](/nl/packages/voicevox-core-php/usage.md)
- [PHP FFI](/nl/advanced/ffi.md)
- [Installatie en configuratie - VOICEVOX for Laravel](/nl/packages/laravel-voicevox/installation.md)
- [Core-package en eigen drivers - Feedable](/nl/packages/feedable/core.md)
