Documentation
¶
Index ¶
- Constants
- func CheckHealth(def *EngineDef, timeout time.Duration) bool
- func HealthURL(baseURL, healthType string) string
- func RenderPlist(def *EngineDef, logDir string) string
- func RenderSystemdUnit(def *EngineDef) string
- func SupportsServiceManagement() bool
- func SystemdUnit(t EngineType) string
- type EngineDef
- type EngineInfo
- type EngineType
- type Registry
- type ServiceManager
- type ServiceStatus
- type UserEngineConfig
Constants ¶
const ( HealthVoicevox = "voicevox" // GET /version HealthOpenAI = "openai" // GET /v1/models )
Health check types.
Variables ¶
This section is empty.
Functions ¶
func CheckHealth ¶ added in v0.1.21
CheckHealth performs an HTTP GET against the engine's health endpoint and reports whether the engine responded with a 2xx status. The timeout bounds the whole request; a default of 2s is used when timeout <= 0.
func HealthURL ¶ added in v0.1.21
HealthURL constructs the health-check URL for the given base URL and health type. It is a pure function to keep it independently testable.
func RenderPlist ¶ added in v0.1.21
RenderPlist builds the launchd plist contents for a managed engine.
For built-in engines (no Dir/Env) the output is byte-identical to the historical embedded templates: a fixed-key dict with Label, ProgramArguments (Command followed by Args), RunAtLoad, KeepAlive and the two log paths. User-defined engines additionally emit WorkingDirectory and EnvironmentVariables blocks when Dir/Env are set. All text nodes derived from user input are XML-escaped to prevent plist structure injection.
func RenderSystemdUnit ¶ added in v0.1.21
RenderSystemdUnit builds the systemd user unit contents for a managed engine.
For built-in engines (no Dir/Env) the output matches the historical embedded templates. User-defined engines additionally emit WorkingDirectory and Environment= lines. Newlines/NUL in user input are rejected upstream (BuildRegistry), and Environment values are quoted/escaped here, so directive injection into the [Service] section is not possible.
func SupportsServiceManagement ¶ added in v0.1.21
func SupportsServiceManagement() bool
SupportsServiceManagement reports whether the current platform has a service manager implementation.
func SystemdUnit ¶
func SystemdUnit(t EngineType) string
SystemdUnit returns the systemd unit name for the engine.
Types ¶
type EngineDef ¶ added in v0.1.21
type EngineDef struct {
Name string // unique engine name (the identifier used as a CLI argument)
DisplayName string
BaseURL string // health check base, e.g. http://127.0.0.1:8088
HealthType string // "voicevox" (GET /version) | "openai" (GET /v1/models)
// Service spec. When Command is empty the engine is "external" (not managed
// by ccpersona): only status (health check) is available, no install/start/stop.
Command string
Args []string
Dir string // working directory (~ expanded)
Env map[string]string
// contains filtered or unexported fields
}
EngineDef is the canonical definition of a manageable TTS engine. It unifies built-in engines (VOICEVOX / AivisSpeech) and user-defined engines declared in the voice config file.
func (*EngineDef) Builtin ¶ added in v0.1.21
Builtin reports whether the engine is a built-in (VOICEVOX/AivisSpeech).
func (*EngineDef) HealthURL ¶ added in v0.1.21
HealthURL builds the health-check URL for the engine based on its HealthType.
func (*EngineDef) Managed ¶ added in v0.1.21
Managed reports whether ccpersona owns a service identity for the engine and can manage lifecycle operations. Built-ins remain manageable even when binary discovery fails, so users can stop or uninstall a previously installed service after the app binary moved or was removed. Install still requires a Command because rendering a new service file needs the executable path.
func (*EngineDef) ServiceLabel ¶ added in v0.1.21
ServiceLabel returns the launchd label / systemd unit base name used to identify the managed service. Built-ins keep their historical names.
func (*EngineDef) SystemdUnitName ¶ added in v0.1.21
SystemdUnitName returns the systemd unit filename for the engine.
type EngineInfo ¶
type EngineInfo struct {
Type EngineType
BinaryPath string
Port int
Label string // service label (e.g. "com.voicevox.engine")
}
EngineInfo holds discovered engine information.
func DiscoverEngine ¶
func DiscoverEngine(t EngineType) (*EngineInfo, error)
DiscoverEngine searches for the engine binary on the system.
func (*EngineInfo) PortString ¶
func (e *EngineInfo) PortString() string
PortString returns the port as a string.
type EngineType ¶
type EngineType string
EngineType represents a TTS engine type.
const ( VOICEVOX EngineType = "voicevox" AivisSpeech EngineType = "aivisspeech" )
func AllEngineTypes ¶
func AllEngineTypes() []EngineType
AllEngineTypes returns all supported engine types.
func ParseEngineType ¶
func ParseEngineType(s string) ([]EngineType, error)
ParseEngineType parses a string into an EngineType. Returns all engine types for "all".
type Registry ¶ added in v0.1.21
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the set of known engines, keyed by name, preserving a stable ordering (built-ins first in declaration order, then user-defined sorted by name).
func BuildRegistry ¶ added in v0.1.21
func BuildRegistry(userEngines map[string]UserEngineConfig) (*Registry, error)
BuildRegistry constructs a registry from the built-in engines plus the given user-defined engines. A user engine whose name collides with a built-in is rejected (override is not allowed, to avoid confusion).
func (*Registry) Get ¶ added in v0.1.21
Get returns the engine definition for a name, or false if unknown.
type ServiceManager ¶
type ServiceManager interface {
// Install deploys the service configuration file and enables the service.
Install(def *EngineDef) error
// Uninstall stops and removes the service configuration.
Uninstall(def *EngineDef) error
// Start starts the service.
Start(def *EngineDef) error
// Stop stops the service.
Stop(def *EngineDef) error
// Status returns the service status.
Status(def *EngineDef) (*ServiceStatus, error)
}
ServiceManager manages TTS engine background services.
func NewServiceManager ¶
func NewServiceManager() (ServiceManager, error)
NewServiceManager returns the appropriate platform implementation.
type ServiceStatus ¶
type ServiceStatus struct {
Name string
Installed bool
Running bool
PID int
Label string // launchd label or systemd unit name
}
ServiceStatus represents the status of a managed engine service.
type UserEngineConfig ¶ added in v0.1.21
type UserEngineConfig struct {
BaseURL string
Health string // "voicevox" | "openai"; defaults to "openai" when empty
Command string
Args []string
Dir string
Env map[string]string
}
UserEngineConfig is the engine definition supplied by the user in the voice config file. It mirrors voice.EngineUserConfig but lives in this package to avoid an engine -> voice import (the caller converts and passes these in).