stt-cli 0.2.1

Speech to text Cli using Groq API and OpenAI API
// src/config.rs

use clap::{Parser, ValueEnum};
use std::path::PathBuf;

#[derive(Debug, Clone, ValueEnum, PartialEq)]
pub enum TranscriptionMode {
    AlwaysOn,
    Hotkey,
}

#[derive(Debug, Clone, ValueEnum, PartialEq)]
pub enum TranscriptionProviderAPI {
    Groq,
    OpenAI,
}

#[derive(Parser, Debug, Clone)]
#[command(author, version, about, long_about = None)]
pub struct AppConfig {
    /// Audio device name to use
    #[arg(short, long)]
    pub device: Option<String>,

    /// Transcription activation mode
    #[arg(short, long, value_enum, default_value = "always-on")]
    pub mode: TranscriptionMode,

    /// Hotkey for toggling recording (when in hotkey mode)
    #[arg(short = 'k', long, default_value = "ctrl+space")]
    pub hotkey: String,

    /// Directory to store data
    #[arg(long, default_value = "data_dir")]
    pub data_dir: PathBuf,

    /// Enable debug mode
    #[arg(long)]
    pub debug: bool,

    /// Transcription provider
    #[arg(short, long, value_enum, default_value = "groq")]
    pub transcription_provider: TranscriptionProviderAPI,

    /// Enable text insertion at cursor position
    #[arg(long, default_value = "true")]
    pub enable_text_insertion: bool,

    /// Automatically capitalize first letter of transcribed text
    #[arg(long, default_value = "true")]
    pub auto_capitalize: bool,

    /// Automatically add trailing punctuation if missing
    #[arg(long, default_value = "true")]
    pub auto_punctuate: bool,
}

impl AppConfig {
    pub fn parse() -> Result<Self, clap::Error> {
        Self::try_parse()
    }
}

impl Default for AppConfig {
    fn default() -> Self {
        Self {
            device: None,
            mode: TranscriptionMode::AlwaysOn,
            hotkey: "ctrl+space".to_string(),
            data_dir: PathBuf::from("data_dir"),
            debug: false,
            transcription_provider: TranscriptionProviderAPI::Groq,
            enable_text_insertion: true,
            auto_capitalize: true,
            auto_punctuate: true,
        }
    }
}