Gorilla.Audio.TTS.Piper Unit Reference

Overview

The Gorilla.Audio.TTS.Piper unit implements TGorillaPiperEngine, a local neural text-to-speech backend driving Piper. The engine registers itself in the initialization section of the unit, so adding the unit to a project makes 'Piper' selectable through EngineName.

Including this unit also activates the espeak-ng library phonemizer, because the Piper releases ship espeak-ng.dll — see Gorilla.Audio.TTS.Visemes.

Piper and its voice models are not part of the Gorilla3D distribution. See Getting Piper.

Class Hierarchy

TGorillaTTSEngine
  └── TGorillaPiperEngine

Enumerations

TGorillaPiperMode

Value Description
pmProcess Spawns the Piper executable for every utterance
pmHttp Sends the text to a running Piper HTTP server

TGorillaPiperEngine

Class Methods

Method Description
GetEngineName() Returns 'Piper'
IsSupported() False where the mode cannot work, e.g. pmProcess on mobile

Public Methods

Method Description
IsAvailable() True when executable and model were resolved
GetVoices() All voices found in ModelDirectory; multi-speaker models report each speaker as model.onnx#3
RefreshVoices() Rescans ModelDirectory
ResolveExecutable() The executable that would actually be called, resolved against the system search path and the release layouts next to the application. Empty when Piper was not found

Published Properties

Property Type Default Description
Mode TGorillaPiperMode pmProcess How the engine reaches Piper
ExecutablePath String — Path of the Piper executable; a bare name like piper is searched on the system path
ModelPath String — Model used when neither the request nor DefaultVoice names one
ModelDirectory String — Folder scanned for *.onnx voice models
EspeakDataPath String — Folder holding the espeak-ng data files; only needed when Piper does not find them itself
ServerUrl String http://127.0.0.1:5000 Base address of the HTTP server in pmHttp
HttpPath String — Resource path appended to ServerUrl
CommandTemplate String see below Command line used in pmProcess
Timeout Integer 30000 Milliseconds a single synthesis may take
NoiseW Single 0.8 Piper noise-w parameter, controls the variation of phoneme lengths
CudaEnabled Boolean False Adds --cuda to the command line

Inherited from TGorillaTTSEngine: DefaultVoice, DefaultLanguage, Lipsync.

Protected Methods (for implementers)

Method Description
ResolveModel(AVoiceId, out AModel, ...) Splits a voice identifier of the form model.onnx#speaker and resolves the model into an absolute path
ReadModelConfig(AModelFile, ...) Reads the .onnx.json configuration next to a model file
DoSynthesizeProcess(...) Synthesis by spawning the executable
DoSynthesizeHttp(...) Synthesis against the HTTP server

Search Order

When ExecutablePath and ModelDirectory are empty, the engine searches next to the application:

Kind Locations
Executable piper\piper.exe, piper.exe, Piper\piper\piper.exe
Voices piper\voices, voices, models

Constants

GORILLA_PIPER_COMMAND

Default command line of the Piper executable:

%EXE% --model %MODEL% --output_file %OUTPUT%
      --length_scale %LENGTH_SCALE% --noise_scale %NOISE_SCALE%
      --noise_w %NOISE_W% --sentence_silence %SENTENCE_SILENCE%
      %SPEAKER%%ESPEAK_DATA%%CUDA%

Placeholders: %EXE%, %MODEL%, %OUTPUT%, %LENGTH_SCALE%, %NOISE_SCALE%, %NOISE_W%, %SENTENCE_SILENCE%, %SPEAKER%, %ESPEAK_DATA%, %CUDA%.

The template matches rhasspy/piper 1.2.0, the version the backend was tested against. If your Piper version expects a different command line, only CommandTemplate needs adjusting.

GORILLA_PIPER_SERVER

Default address of a local Piper HTTP server: http://127.0.0.1:5000.

Remarks

There is no Piper library to link against: piper_phonemize.dll only exports C++-mangled functions with std::vector / std::string parameters, and the actual VITS inference lives inside piper.exe. The only usable parts of the release archives are espeak-ng.dll and, in principle, onnxruntime.dll — whose C API would require reimplementing the whole Piper inference.

Every voice consists of two files that belong together: <voice>.onnx and <voice>.onnx.json. The .json carries the sample rate and the speaker list; a model without it cannot be used.

See Also