diff --git a/VoiceInk/HotkeyManager.swift b/VoiceInk/HotkeyManager.swift index 188d1b4..1f0aa34 100644 --- a/VoiceInk/HotkeyManager.swift +++ b/VoiceInk/HotkeyManager.swift @@ -59,7 +59,7 @@ class HotkeyManager: ObservableObject { // Key state tracking private var currentKeyState = false private var keyPressStartTime: Date? - private let briefPressThreshold = 0.8 + private let briefPressThreshold = 1.7 private var isHandsFreeMode = false // Debounce for Fn key diff --git a/VoiceInk/SoundManager.swift b/VoiceInk/SoundManager.swift index e3f57c7..d0e278a 100644 --- a/VoiceInk/SoundManager.swift +++ b/VoiceInk/SoundManager.swift @@ -12,29 +12,33 @@ class SoundManager { @AppStorage("isSoundFeedbackEnabled") private var isSoundFeedbackEnabled = true private init() { - setupSounds() + Task(priority: .background) { + await setupSounds() + } } - private func setupSounds() { + private func setupSounds() async { // Try loading directly from the main bundle if let startSoundURL = Bundle.main.url(forResource: "recstart", withExtension: "mp3"), let stopSoundURL = Bundle.main.url(forResource: "recstop", withExtension: "mp3"), let escSoundURL = Bundle.main.url(forResource: "esc", withExtension: "wav") { - try? loadSounds(start: startSoundURL, stop: stopSoundURL, esc: escSoundURL) + try? await loadSounds(start: startSoundURL, stop: stopSoundURL, esc: escSoundURL) return } } - private func loadSounds(start startURL: URL, stop stopURL: URL, esc escURL: URL) throws { + private func loadSounds(start startURL: URL, stop stopURL: URL, esc escURL: URL) async throws { do { startSound = try AVAudioPlayer(contentsOf: startURL) stopSound = try AVAudioPlayer(contentsOf: stopURL) escSound = try AVAudioPlayer(contentsOf: escURL) // Prepare sounds for instant playback first - startSound?.prepareToPlay() - stopSound?.prepareToPlay() - escSound?.prepareToPlay() + await MainActor.run { + startSound?.prepareToPlay() + stopSound?.prepareToPlay() + escSound?.prepareToPlay() + } // Set lower volume for all sounds after preparation startSound?.volume = 0.4