stt-cli 0.2.1

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

use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

#[derive(Debug, Clone)]
pub struct RecordingState {
    pub active: Arc<AtomicBool>,
}

impl RecordingState {
    pub fn new(initially_active: bool) -> Self {
        Self {
            active: Arc::new(AtomicBool::new(initially_active)),
        }
    }

    pub fn set_active(&self, active: bool) {
        self.active.store(active, Ordering::SeqCst);
    }

    pub fn is_active(&self) -> bool {
        self.active.load(Ordering::SeqCst)
    }

    pub fn toggle(&self) -> bool {
        let previous = self.active.fetch_xor(true, Ordering::SeqCst);
        !previous
    }
}