using System.Text.Json; namespace VoiceCat.App.Notifications; /// /// User preferences for event sounds and spoken (text-to-speech) feedback. Persisted to /// %AppData%\VoiceCat\feedback.json — same pattern as : /// a missing or corrupt file yields defaults rather than throwing. /// public sealed class FeedbackSettings { /// Master switch for event sound effects. public bool Sounds { get; set; } = true; /// Master switch for spoken announcements (Prismatoid TTS). Off by default. public bool Speech { get; set; } = false; /// Sound-effects volume, 0..1. 0 mutes effects (SoundPlayer has no gain control, /// so this is honoured as a mute gate — see ). public float Volume { get; set; } = 1.0f; /// Play va_start/va_stop for your own voice-activity transitions. Off by default /// (fires on every utterance — noisy). public bool SelfTalkSounds { get; set; } = false; /// Play the ptt cue when push-to-talk is engaged. Off by default. public bool PttSound { get; set; } = false; private static readonly JsonSerializerOptions JsonOptions = new() { WriteIndented = true }; private static string AppDataDir => Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VoiceCat"); private static string FilePath => Path.Combine(AppDataDir, "feedback.json"); public static FeedbackSettings Load() { try { if (!File.Exists(FilePath)) return new FeedbackSettings(); string json = File.ReadAllText(FilePath); return JsonSerializer.Deserialize(json) ?? new FeedbackSettings(); } catch { return new FeedbackSettings(); } } public void Save() { Directory.CreateDirectory(AppDataDir); File.WriteAllText(FilePath, JsonSerializer.Serialize(this, JsonOptions)); } }