Documentation
¶
Index ¶
- Constants
- func GenerateExampleConfig() string
- func IsMuted() bool
- func MutePath() (string, error)
- func NormalizeReadingMode(mode string) string
- func StripMarkdown(text string) string
- func Unmute() error
- type AudioQuery
- type Config
- type ConfigFile
- func (c *ConfigFile) GetDefaultSpeed() float64
- func (c *ConfigFile) GetDefaultVolume() float64
- func (c *ConfigFile) GetEffectiveProvider(explicit string) string
- func (c *ConfigFile) GetProviderConfig(providerName string) *ProviderConfig
- func (c *ConfigFile) MaskSecrets() *ConfigFile
- func (c *ConfigFile) Validate() []string
- type ConfigLoader
- type DedupTracker
- type DefaultsConfig
- type EngineUserConfig
- type MuteStatus
- type PersonaVoiceInput
- type PlaybackGate
- type ProviderConfig
- type TranscriptMessage
- type TranscriptReader
- type VoiceConfigFiledeprecated
- type VoiceConfigLoaderdeprecated
- type VoiceEngine
- func (ve *VoiceEngine) CheckEngines() (voicevoxAvailable, aivisSpeechAvailable bool)
- func (ve *VoiceEngine) Play(audioFile string) error
- func (ve *VoiceEngine) PlayWithOptions(audioFile string, wait bool) error
- func (ve *VoiceEngine) SelectEngine() (string, error)
- func (ve *VoiceEngine) Synthesize(text string) (string, error)
- type VoiceManager
- func (vm *VoiceManager) CleanupTempFiles(maxAge time.Duration) error
- func (vm *VoiceManager) ListVoices(ctx context.Context, providerName string) ([]provider.Voice, error)
- func (vm *VoiceManager) PlayAudio(audioPath string) error
- func (vm *VoiceManager) PlayAudioBlocking(audioPath string) error
- func (vm *VoiceManager) Synthesize(ctx context.Context, text string, options VoiceOptions) (string, error)
- type VoiceOptions
Constants ¶
const ( ModeShort = "short" // Read first line only ModeFull = "full" // Read full text (with optional char limit) )
ReadingMode constants Primary modes (recommended):
const ( ModeFirstLine = "first_line" // Alias for "short" ModeLineLimit = "line_limit" // Deprecated: use "full" with --chars ModeAfterFirst = "after_first" // Deprecated: use "full" ModeFullText = "full_text" // Alias for "full" ModeCharLimit = "char_limit" // Alias for "full" with --chars )
Legacy mode aliases for backward compatibility:
const ( EngineVoicevox = "voicevox" EngineAivisSpeech = "aivisspeech" )
Engine constants
const ( VoicevoxURL = "http://127.0.0.1:50021" AivisSpeechURL = "http://127.0.0.1:10101" )
Default engine URLs
Variables ¶
This section is empty.
Functions ¶
func GenerateExampleConfig ¶ added in v0.1.6
func GenerateExampleConfig() string
GenerateExampleConfig generates an example configuration
func IsMuted ¶ added in v0.1.20
func IsMuted() bool
IsMuted reports whether global voice synthesis is currently muted. Errors (e.g. missing HOME) are treated as "not muted" so the gate fails open and does not break hook-driven callers.
func MutePath ¶ added in v0.1.20
MutePath returns the canonical absolute path to the mute marker file (~/.agents/ccpersona/mute). The marker's existence means voice synthesis is globally muted.
func NormalizeReadingMode ¶ added in v0.1.6
NormalizeReadingMode converts legacy mode names to canonical names
func StripMarkdown ¶
StripMarkdown removes markdown formatting using mdstrip if available
Types ¶
type AudioQuery ¶
type AudioQuery struct {
Text string `json:"text"`
SpeedScale float64 `json:"speedScale"`
PitchScale float64 `json:"pitchScale"`
VolumeScale float64 `json:"volumeScale"`
PrePhonemeLength float64 `json:"prePhonemeLength"`
PostPhonemeLength float64 `json:"postPhonemeLength"`
}
AudioQuery represents the audio query for voice synthesis
type Config ¶
type Config struct {
// Engine settings
EnginePriority string `json:"engine_priority"` // "voicevox" or "aivisspeech"
VoicevoxSpeaker int `json:"voicevox_speaker"` // VOICEVOX speaker ID
AivisSpeechSpeaker int64 `json:"aivisspeech_speaker"` // AivisSpeech speaker ID
VolumeScale float64 `json:"volume_scale"` // Volume scale (0.0-2.0, default 1.0)
SpeedScale float64 `json:"speed_scale"` // Speed scale (0.5-2.0, default 1.0)
// Reading settings
ReadingMode string `json:"reading_mode"` // short (first line) or full (entire text)
MaxChars int `json:"max_chars"` // Character limit for 'full' mode (0 = unlimited)
// Processing settings
UUIDMode bool `json:"uuid_mode"` // Use UUID search mode (slower but complete)
}
Config represents voice synthesis configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default voice configuration
type ConfigFile ¶ added in v0.1.9
type ConfigFile struct {
DefaultProvider string `json:"default_provider,omitempty"`
Providers map[string]ProviderConfig `json:"providers,omitempty"`
Defaults *DefaultsConfig `json:"defaults,omitempty"`
// Engines declares user-defined local TTS engines that the `engine`
// subcommand can manage (status/start/stop/install) alongside the built-in
// VOICEVOX / AivisSpeech engines. Keyed by unique engine name.
Engines map[string]EngineUserConfig `json:"engines,omitempty"`
}
ConfigFile represents the ccpersona configuration file structure
func (*ConfigFile) GetDefaultSpeed ¶ added in v0.1.9
func (c *ConfigFile) GetDefaultSpeed() float64
GetDefaultSpeed returns the default speed setting
func (*ConfigFile) GetDefaultVolume ¶ added in v0.1.9
func (c *ConfigFile) GetDefaultVolume() float64
GetDefaultVolume returns the default volume setting
func (*ConfigFile) GetEffectiveProvider ¶ added in v0.1.9
func (c *ConfigFile) GetEffectiveProvider(explicit string) string
GetEffectiveProvider returns the provider to use (explicit or default)
func (*ConfigFile) GetProviderConfig ¶ added in v0.1.9
func (c *ConfigFile) GetProviderConfig(providerName string) *ProviderConfig
GetProviderConfig returns configuration for a specific provider
func (*ConfigFile) MaskSecrets ¶ added in v0.1.9
func (c *ConfigFile) MaskSecrets() *ConfigFile
MaskSecrets masks sensitive values in config for display For security, only shows that a key is present, not its contents
func (*ConfigFile) Validate ¶ added in v0.1.9
func (c *ConfigFile) Validate() []string
Validate validates the configuration
type ConfigLoader ¶ added in v0.1.9
type ConfigLoader struct {
// contains filtered or unexported fields
}
ConfigLoader handles loading configuration from files
func NewConfigLoader ¶ added in v0.1.9
func NewConfigLoader() *ConfigLoader
NewConfigLoader creates a new config loader
func NewVoiceConfigLoader
deprecated
added in
v0.1.6
func NewVoiceConfigLoader() *ConfigLoader
Deprecated: NewVoiceConfigLoader is deprecated, use NewConfigLoader instead
func (*ConfigLoader) LoadConfig ¶ added in v0.1.9
func (l *ConfigLoader) LoadConfig(workDir string) (*ConfigFile, error)
LoadConfig loads configuration with priority: 1. Project-local config (.claude/config.json) 2. Global config (~/.claude/config.json) Returns nil if no config file found
func (*ConfigLoader) LoadFromPath ¶ added in v0.1.9
func (l *ConfigLoader) LoadFromPath(path string) (*ConfigFile, error)
LoadFromPath loads configuration from a specific path For security, it validates that the path doesn't traverse outside expected directories
type DedupTracker ¶ added in v0.1.11
type DedupTracker struct {
// contains filtered or unexported fields
}
DedupTracker tracks previously synthesized messages to avoid duplicates. State is stored per session in the OS temp directory.
func NewDedupTracker ¶ added in v0.1.11
func NewDedupTracker(sessionID string) *DedupTracker
NewDedupTracker creates a tracker for the given session.
func (*DedupTracker) Cleanup ¶ added in v0.1.11
func (dt *DedupTracker) Cleanup()
Cleanup removes markers older than 24 hours.
func (*DedupTracker) IsDuplicate ¶ added in v0.1.11
func (dt *DedupTracker) IsDuplicate(text string) bool
IsDuplicate returns true if this text was already synthesized in the current session.
func (*DedupTracker) Record ¶ added in v0.1.11
func (dt *DedupTracker) Record(text string)
Record stores the hash of the synthesized text for this session.
type DefaultsConfig ¶ added in v0.1.9
type DefaultsConfig struct {
Volume float64 `json:"volume,omitempty"`
Speed float64 `json:"speed,omitempty"`
}
DefaultsConfig represents default values for voice synthesis
type EngineUserConfig ¶ added in v0.1.21
type EngineUserConfig struct {
BaseURL string `json:"base_url,omitempty"`
Health string `json:"health,omitempty"` // "voicevox" | "openai"
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Dir string `json:"dir,omitempty"`
Env map[string]string `json:"env,omitempty"`
}
EngineUserConfig declares a user-defined TTS engine for the `engine` subcommand. A definition without Command is treated as externally managed (status/health only). Health defaults to "openai" when omitted.
type MuteStatus ¶ added in v0.1.20
type MuteStatus struct {
MutedAt time.Time `json:"muted_at"`
Reason string `json:"reason,omitempty"`
}
MuteStatus represents the global mute state snapshot.
func LoadMuteStatus ¶ added in v0.1.20
func LoadMuteStatus() (*MuteStatus, error)
LoadMuteStatus returns the current mute status. Returns (nil, nil) when not muted. When the marker file exists but is unparseable, returns a zero-value status so callers still treat the session as muted.
func Mute ¶ added in v0.1.20
func Mute(reason string) (*MuteStatus, error)
Mute enables the global mute. Idempotent: refreshes MutedAt and Reason.
type PersonaVoiceInput ¶ added in v0.1.12
PersonaVoiceInput carries voice settings from a persona config, avoiding a direct import of the persona package.
type PlaybackGate ¶ added in v0.1.13
type PlaybackGate struct {
// contains filtered or unexported fields
}
PlaybackGate はアプリ起動中に再生を直列化する
func NewPlaybackGate ¶ added in v0.1.13
func NewPlaybackGate() *PlaybackGate
NewPlaybackGate はプロセス共有のグローバル PlaybackGate を返す
func (*PlaybackGate) PlayBlocking ¶ added in v0.1.13
func (g *PlaybackGate) PlayBlocking(engine *VoiceEngine, audioFile string) error
PlayBlocking は再生を mutex で直列化し、完了まで待機する
type ProviderConfig ¶ added in v0.1.6
type ProviderConfig struct {
// Common options
APIKey string `json:"api_key,omitempty"`
Voice string `json:"voice,omitempty"`
Model string `json:"model,omitempty"`
Format string `json:"format,omitempty"`
Speed float64 `json:"speed,omitempty"`
// Local engine options (VOICEVOX/AivisSpeech)
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Speaker int `json:"speaker,omitempty"`
// OpenAI options
// (uses common options)
// BaseURL overrides the API endpoint, enabling OpenAI-compatible local TTS
// servers (e.g. Irodori-TTS, kani-tts). When set, api_key becomes optional.
BaseURL string `json:"base_url,omitempty"`
// TimeoutSeconds overrides the HTTP request timeout (default 30). Local GPU
// inference can be slow on the first request.
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
// ElevenLabs options
Stability float64 `json:"stability,omitempty"`
SimilarityBoost float64 `json:"similarity_boost,omitempty"`
Style float64 `json:"style,omitempty"`
UseSpeakerBoost *bool `json:"use_speaker_boost,omitempty"`
// Amazon Polly options
Region string `json:"region,omitempty"`
Engine string `json:"engine,omitempty"`
SampleRate string `json:"sample_rate,omitempty"`
// Volume control (provider-specific override)
Volume float64 `json:"volume,omitempty"`
}
ProviderConfig represents provider-specific configuration
type TranscriptMessage ¶
type TranscriptMessage struct {
Type string `json:"type"`
UUID string `json:"uuid,omitempty"`
Message struct {
Role string `json:"role"`
Content []struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
} `json:"content"`
} `json:"message,omitempty"`
}
TranscriptMessage represents a message in Claude Code transcript
type TranscriptReader ¶
type TranscriptReader struct {
// contains filtered or unexported fields
}
TranscriptReader reads Claude Code transcript files
func NewTranscriptReader ¶
func NewTranscriptReader(config *Config) *TranscriptReader
NewTranscriptReader creates a new transcript reader
func (*TranscriptReader) FindLatestTranscript ¶
func (tr *TranscriptReader) FindLatestTranscript() (string, error)
FindLatestTranscript finds the most recent transcript file
func (*TranscriptReader) GetLatestAssistantMessage ¶
func (tr *TranscriptReader) GetLatestAssistantMessage(transcriptPath string) (string, error)
GetLatestAssistantMessage extracts the latest assistant message from transcript
func (*TranscriptReader) ProcessText ¶
func (tr *TranscriptReader) ProcessText(text string) string
ProcessText applies reading mode restrictions to the text
type VoiceConfigFile
deprecated
added in
v0.1.6
type VoiceConfigFile = ConfigFile
Deprecated: VoiceConfigFile is deprecated, use ConfigFile instead
type VoiceConfigLoader
deprecated
added in
v0.1.6
type VoiceConfigLoader = ConfigLoader
Deprecated: VoiceConfigLoader is deprecated, use ConfigLoader instead
type VoiceEngine ¶
type VoiceEngine struct {
// contains filtered or unexported fields
}
VoiceEngine handles voice synthesis
func NewVoiceEngine ¶
func NewVoiceEngine(config *Config) *VoiceEngine
NewVoiceEngine creates a new voice engine
func (*VoiceEngine) CheckEngines ¶
func (ve *VoiceEngine) CheckEngines() (voicevoxAvailable, aivisSpeechAvailable bool)
CheckEngines checks which voice engines are available
func (*VoiceEngine) Play ¶
func (ve *VoiceEngine) Play(audioFile string) error
Play plays the audio file
func (*VoiceEngine) PlayWithOptions ¶ added in v0.1.9
func (ve *VoiceEngine) PlayWithOptions(audioFile string, wait bool) error
PlayWithOptions plays the audio file with options If wait is true, blocks until playback completes (useful for hooks)
func (*VoiceEngine) SelectEngine ¶
func (ve *VoiceEngine) SelectEngine() (string, error)
SelectEngine selects which engine to use based on availability and priority
func (*VoiceEngine) Synthesize ¶
func (ve *VoiceEngine) Synthesize(text string) (string, error)
Synthesize generates audio from text
type VoiceManager ¶ added in v0.1.5
type VoiceManager struct {
// contains filtered or unexported fields
}
VoiceManager manages both local engines and cloud providers
func NewVoiceManager ¶ added in v0.1.5
func NewVoiceManager(config *Config) *VoiceManager
NewVoiceManager creates a new voice manager
func (*VoiceManager) CleanupTempFiles ¶ added in v0.1.5
func (vm *VoiceManager) CleanupTempFiles(maxAge time.Duration) error
CleanupTempFiles removes temporary audio files older than specified duration
func (*VoiceManager) ListVoices ¶ added in v0.1.5
func (vm *VoiceManager) ListVoices(ctx context.Context, providerName string) ([]provider.Voice, error)
ListVoices lists available voices for all providers
func (*VoiceManager) PlayAudio ¶ added in v0.1.5
func (vm *VoiceManager) PlayAudio(audioPath string) error
PlayAudio plays an audio file using the legacy engine's player
func (*VoiceManager) PlayAudioBlocking ¶ added in v0.1.13
func (vm *VoiceManager) PlayAudioBlocking(audioPath string) error
PlayAudioBlocking plays an audio file with blocking serialization via PlaybackGate. MCP での連続呼び出し時に音が重ならないよう、完了まで待機する。
func (*VoiceManager) Synthesize ¶ added in v0.1.5
func (vm *VoiceManager) Synthesize(ctx context.Context, text string, options VoiceOptions) (string, error)
Synthesize generates audio using the specified provider
type VoiceOptions ¶ added in v0.1.5
type VoiceOptions struct {
Provider string
Voice string
Speed float64
Volume float64 // 0 = use default (1.0)
Format string
Quality string
APIKey string
Model string
// OpenAI-compatible endpoint override (for local TTS servers)
BaseURL string
TimeoutSeconds int
// ElevenLabs-specific options
Stability float64
SimilarityBoost float64
Style float64
UseSpeakerBoost bool
// Local engine speaker override (0 = use Config default)
VoicevoxSpeaker int
AivisSpeechSpeaker int
// Amazon Polly-specific options
Region string
Engine string
SampleRate string
// Output options
OutputPath string
PlayAudio bool
ToStdout bool
}
VoiceOptions contains options for voice synthesis
func Resolve ¶ added in v0.1.12
func Resolve(persona PersonaVoiceInput, fileConfig *ConfigFile, cliProvider string) VoiceOptions
Resolve merges all configuration sources into a single VoiceOptions. VoiceOptions is the single source of truth for resolved settings. Callers that need a *Config (legacy VoiceEngine path) call opts.ToConfig().
Priority (highest → lowest):
- cliProvider argument (provider name only; caller applies CLI speaker/flags after)
- persona (PersonaVoiceInput)
- fileConfig.Providers[effectiveProvider] (per-provider overrides)
- fileConfig.Defaults (global defaults from config file)
- DefaultConfig() hard-coded values
func (VoiceOptions) ToConfig ¶ added in v0.1.14
func (o VoiceOptions) ToConfig(base *Config) *Config
ToConfig converts VoiceOptions into a *Config for the legacy VoiceEngine path. base supplies reading-specific fields (ReadingMode, MaxChars, UUIDMode) that are not part of synthesis options.