config

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config provides configuration management for the md2audio CLI. It handles command-line argument parsing, environment variable loading, voice presets, and configuration validation.

Key features:

  • CLI flag parsing with sensible defaults
  • Voice preset management (british-female, us-male, etc.)
  • Environment variable integration (.env file support)
  • Provider-specific configuration (say, elevenlabs)
  • Configuration validation
  • Secure API key masking in output

Index

Constants

View Source
const DefaultElevenLabsVoiceID = "21m00Tcm4TlvDq8ikWAM"

DefaultElevenLabsVoiceID is the default voice for ElevenLabs (Rachel)

Variables

View Source
var VoicePresets = map[string]string{
	"british-female":    "Kate",
	"british-male":      "Daniel",
	"us-female":         "Samantha",
	"us-male":           "Alex",
	"australian-female": "Karen",
	"indian-female":     "Veena",
}

VoicePresets maps common voice configurations to voice names

Functions

This section is empty.

Types

type CommandFlags

type CommandFlags struct {
	ListVoices   bool   // List all available voices for the selected provider
	RefreshCache bool   // Force refresh voice cache when listing voices
	ExportVoices string // Export cached voices to JSON file (e.g., "voices.json")
	Version      bool   // Print version and exit
	Debug        bool   // Enable debug logging
	DryRun       bool   // Dry-run mode: show what would be generated without creating files
}

CommandFlags holds command-line flags for special operations

type Config

type Config struct {
	// Input/Output Options
	MarkdownFile string // Path to input markdown file (mutually exclusive with InputDir)
	InputDir     string // Path to input directory for recursive processing (mutually exclusive with MarkdownFile)
	OutputDir    string // Path to output directory for generated audio files (default: "./audio_sections")

	// Common Audio Options
	Format string // Output audio format: "aiff", "m4a", or "mp3" (default: "aiff")
	Prefix string // Prefix for output filenames (default: "section")

	// Command Options
	Commands CommandFlags

	// TTS Provider Configuration
	Provider   string           // TTS provider: "say" (macOS) or "elevenlabs" (default: "say")
	Say        SayConfig        // Say provider configuration
	ElevenLabs ElevenLabsConfig // ElevenLabs provider configuration
}

Config holds the application configuration

func Parse

func Parse() Config

Parse parses command-line flags and returns the configuration

func (Config) IsDirectoryMode

func (c Config) IsDirectoryMode() bool

IsDirectoryMode returns true if processing a directory

func (Config) Print

func (c Config) Print()

Print displays the configuration NOTE: This method is safe for logging - sensitive data (API keys) are never printed

func (Config) Validate

func (c Config) Validate() error

Validate checks if the configuration is valid

type ElevenLabsConfig

type ElevenLabsConfig struct {
	VoiceID       string        // ElevenLabs voice ID (required when using elevenlabs provider)
	Model         string        // ElevenLabs model ID (default: "eleven_multilingual_v2")
	APIKey        string        // ElevenLabs API key (prefer ELEVENLABS_API_KEY env var)
	VoiceSettings VoiceSettings // Voice generation settings (loaded from environment variables with defaults)
}

ElevenLabsConfig holds configuration for the ElevenLabs provider

type SayConfig

type SayConfig struct {
	Voice string // Voice name (default: "Kate")
	Rate  int    // Speaking rate in words per minute (default: 180)
}

SayConfig holds configuration for the macOS say provider

type VoiceSettings

type VoiceSettings struct {
	Stability       float64 // Voice consistency (0.0-1.0, default: 0.5, higher = more consistent but less expressive)
	SimilarityBoost float64 // Voice similarity to original (0.0-1.0, default: 0.5, higher = closer to voice characteristics)
	Style           float64 // Voice style/emotional range (0.0-1.0, default: 0.0 = disabled, higher = more expressive)
	UseSpeakerBoost bool    // Boost similarity of synthesized speech (default: true)
	Speed           float64 // Speaking speed multiplier (0.7-1.2, default: 1.0, only for non-timed sections)
}

VoiceSettings holds ElevenLabs voice generation settings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL