メインコンテンツへスキップ

Onnxruntime

ONNX Runtime ローダー。プロセスレベルのシングルトンで、1 プロセスにつき 1 インスタンスのみ存在します。

メソッド

メソッド説明
static loadOnce(string $filename = ''): selfONNX Runtime を読み込んで初期化します。2 回目以降の呼び出しでは引数を無視して既存のインスタンスを返します。
static get(): ?self既存のインスタンスを返します。まだ初期化されていない場合は null を返します。
supportedDevices(): string利用可能なデバイス情報を JSON 文字列で返します。
static libVersionedFilename(): stringONNX Runtime ライブラリのバージョン付きファイル名を返します(例: libvoicevox_onnxruntime.1.17.3.dylib)。
static libUnversionedFilename(): stringONNX Runtime ライブラリのバージョンなしファイル名を返します。

定数

定数説明
LIB_NAMEライブラリベース名(voicevox_onnxruntime
LIB_VERSION推奨 ONNX Runtime バージョン

OpenJtalk

OpenJTalk を使ったテキスト解析器。

メソッド

メソッド説明
__construct(string $openJtalkDictDir)OpenJTalk 辞書ディレクトリのパスで初期化します。
analyze(string $text): string日本語テキストを解析し、アクセント句配列の JSON を返します。
useUserDict(UserDict $userDict): voidユーザー辞書を適用します。辞書が変更された場合は再度呼び出す必要があります。

VoiceModelFile

音声モデルファイル(.vvm ファイル)。

メソッド

メソッド説明
static open(string $path): self.vvm ファイルを開きます。
id(): string音声モデル ID を hex 文字列(16 バイト)で返します。
createMetasJson(): stringスピーカーメタデータを JSON 文字列で返します。
close(): voidファイルを閉じてリソースを解放します。

Synthesizer

テキスト読み上げのメインクラス。

メソッド

メソッド説明
__construct(Onnxruntime $onnxruntime, OpenJtalk $openJtalk, AccelerationMode $accelerationMode = Auto, int $cpuNumThreads = 0)シンセサイザーを初期化します。
onnxruntime(): Onnxruntimeこのシンセサイザーが保持する Onnxruntime インスタンスを返します。
isGpuMode(): boolGPU モードが有効かどうかを返します。
metas(): string読み込まれているスピーカーのメタデータを JSON 文字列で返します。
loadVoiceModel(VoiceModelFile $model): void音声モデルを読み込みます。
unloadVoiceModel(string $voiceModelId): voidhex ID で指定した音声モデルをアンロードします。
isLoadedVoiceModel(string $voiceModelId): bool音声モデルが読み込まれているかどうかを確認します。
createAudioQuery(string $text, int $styleId): string日本語テキストから AudioQuery JSON を生成します。
createAudioQueryFromKana(string $kana, int $styleId): stringAquesTalk スタイルのかな記法から AudioQuery JSON を生成します。
createAccentPhrases(string $text, int $styleId): string日本語テキストからアクセント句配列 JSON を生成します。
createAccentPhrasesFromKana(string $kana, int $styleId): stringかな記法からアクセント句配列 JSON を生成します。
replaceMoraData(string $accentPhrasesJson, int $styleId): stringモーラのピッチと音素長を更新した新しいアクセント句を返します。
replacePhonemeLength(string $accentPhrasesJson, int $styleId): string音素長を更新した新しいアクセント句を返します。
replaceMoraPitch(string $accentPhrasesJson, int $styleId): stringモーラのピッチを更新した新しいアクセント句を返します。
synthesis(string $audioQueryJson, int $styleId, bool $enableInterrogativeUpspeak = true): stringAudioQuery JSON から音声を合成します。WAV バイナリを返します。
tts(string $text, int $styleId, bool $enableInterrogativeUpspeak = true): string日本語テキストから 1 ステップで音声を合成します。WAV バイナリを返します。
ttsFromKana(string $kana, int $styleId, bool $enableInterrogativeUpspeak = true): stringかな記法から音声を合成します。WAV バイナリを返します。
createSingFrameAudioQuery(string $scoreJson, int $styleId): string楽譜 JSON から歌唱合成クエリ JSON を生成します。
frameSynthesis(string $frameAudioQueryJson, int $styleId): stringフレームオーディオクエリから歌唱音声を合成します。WAV バイナリを返します。
createSingFrameF0(string $scoreJson, string $frameAudioQueryJson, int $styleId): string楽譜と歌唱クエリからフレームごとの F0(基本周波数)を JSON の float 配列で返します。
createSingFrameVolume(string $scoreJson, string $frameAudioQueryJson, int $styleId): string楽譜と歌唱クエリからフレームごとの音量を JSON の float 配列で返します。

VoicevoxCore

VOICEVOX Core のグローバルユーティリティ関数。

メソッド

メソッド説明
static getVersion(): stringVOICEVOX Core のバージョンを SemVer 文字列で返します。
static audioQueryCreateFromAccentPhrases(string $accentPhrasesJson): stringアクセント句配列 JSON から AudioQuery JSON を生成します。
static audioQueryValidate(string $audioQueryJson): voidAudioQuery JSON を検証します。不正な場合は VoicevoxException をスローします。
static accentPhraseValidate(string $accentPhraseJson): voidAccentPhrase JSON を検証します。不正な場合は VoicevoxException をスローします。
static moraValidate(string $moraJson): voidMora JSON を検証します。不正な場合は VoicevoxException をスローします。
static scoreValidate(string $scoreJson): voidScore JSON を検証します。不正な場合は VoicevoxException をスローします。
static noteValidate(string $noteJson): voidNote JSON を検証します。不正な場合は VoicevoxException をスローします。
static frameAudioQueryValidate(string $frameAudioQueryJson): voidFrameAudioQuery JSON を検証します。不正な場合は VoicevoxException をスローします。
static framePhonemeValidate(string $framePhonemeJson): voidFramePhoneme JSON を検証します。不正な場合は VoicevoxException をスローします。
static ensureCompatible(string $scoreJson, string $frameAudioQueryJson): void楽譜と歌唱音声合成クエリの組み合わせが有効かを確認します。不正な場合は VoicevoxException をスローします。

UserDict

カスタム単語の発音を登録するユーザー辞書。

メソッド

メソッド説明
__construct()空のユーザー辞書を作成します。
load(string $path): voidファイルからユーザー辞書を読み込みます。
save(string $path): voidユーザー辞書をファイルに保存します。
addWord(string $surface, string $pronunciation, int $accentType, UserDictWordType $wordType = CommonNoun, int $priority = 5): string単語を追加します。単語 UUID を hex 文字列で返します。
updateWord(string $wordUuid, string $surface, string $pronunciation, int $accentType, UserDictWordType $wordType = CommonNoun, int $priority = 5): voidUUID で指定した既存の単語を更新します。
removeWord(string $wordUuid): voidUUID で指定した単語を削除します。
importDict(UserDict $other): void別の UserDict から単語をインポートします。
toJson(): stringすべての単語を JSON 文字列で返します。

Enum: AccelerationMode

シンセサイザーのハードウェアアクセラレーションモード。
Case説明
Auto0利用可能な最適モードを自動選択します。
Cpu1CPU モードを強制します。
Gpu2GPU モードを強制します。

Enum: UserDictWordType

ユーザー辞書エントリの品詞。
Case説明
ProperNoun0固有名詞
CommonNoun1一般名詞
Verb2動詞
Adjective3形容詞
Suffix4接尾辞

VoicevoxException

VOICEVOX Core の C API 呼び出しがエラーコードを返した場合にスローされます。例外メッセージにはライブラリからのエラー説明が含まれます。
Last modified on May 19, 2026