diff --git a/src-tauri/resources/rec.wav b/src-tauri/resources/rec.wav deleted file mode 100644 index 5910d1f..0000000 Binary files a/src-tauri/resources/rec.wav and /dev/null differ diff --git a/src-tauri/resources/rec_start.wav b/src-tauri/resources/rec_start.wav new file mode 100644 index 0000000..f2d01c5 Binary files /dev/null and b/src-tauri/resources/rec_start.wav differ diff --git a/src-tauri/resources/rec_stop.wav b/src-tauri/resources/rec_stop.wav new file mode 100644 index 0000000..6ac2b61 Binary files /dev/null and b/src-tauri/resources/rec_stop.wav differ diff --git a/src-tauri/src/actions.rs b/src-tauri/src/actions.rs index 205d833..56ccd61 100644 --- a/src-tauri/src/actions.rs +++ b/src-tauri/src/actions.rs @@ -2,7 +2,8 @@ use crate::managers::audio::AudioRecordingManager; use crate::managers::transcription::TranscriptionManager; use crate::utils; use crate::utils::change_tray_icon; -use crate::utils::play_recording_sound; +use crate::utils::play_recording_start_sound; +use crate::utils::play_recording_stop_sound; use crate::utils::TrayIconState; use once_cell::sync::Lazy; use std::collections::HashMap; @@ -25,7 +26,7 @@ impl ShortcutAction for TranscribeAction { change_tray_icon(app, TrayIconState::Recording); // Play audio feedback for recording start - play_recording_sound(app); + play_recording_start_sound(app); let rm = app.state::>(); rm.try_start_recording(&binding_id); @@ -39,7 +40,7 @@ impl ShortcutAction for TranscribeAction { change_tray_icon(app, TrayIconState::Idle); // Play audio feedback for recording stop - play_recording_sound(app); + play_recording_stop_sound(app); let binding_id = binding_id.to_string(); // Clone binding_id for the async task diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs index 0934b43..cf5edc6 100644 --- a/src-tauri/src/settings.rs +++ b/src-tauri/src/settings.rs @@ -48,7 +48,7 @@ pub fn get_default_settings() -> AppSettings { AppSettings { bindings, push_to_talk: true, - audio_feedback: true, + audio_feedback: false, } } diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index 3fd7877..6dd752f 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -87,7 +87,9 @@ pub fn change_tray_icon(app: &AppHandle, icon: TrayIconState) { )); } -pub fn play_recording_sound(app: &AppHandle) { +/// Plays an audio resource from the resources directory. +/// Checks if audio feedback is enabled in settings before playing. +pub fn play_sound(app: &AppHandle, resource_path: &str) { // Check if audio feedback is enabled let settings = settings::get_settings(app); if !settings.audio_feedback { @@ -95,28 +97,42 @@ pub fn play_recording_sound(app: &AppHandle) { } let app_handle = app.clone(); + let resource_path = resource_path.to_string(); // Spawn a new thread to play the audio without blocking the main thread thread::spawn(move || { - // Get the path to the rec.wav file in resources + // Get the path to the audio file in resources let audio_path = match app_handle .path() - .resolve("resources/rec.wav", tauri::path::BaseDirectory::Resource) + .resolve(&resource_path, tauri::path::BaseDirectory::Resource) { Ok(path) => path, Err(e) => { - eprintln!("Failed to resolve audio file path: {}", e); + eprintln!( + "Failed to resolve audio file path '{}': {}", + resource_path, e + ); return; } }; // Try to play the audio file if let Err(e) = play_audio_file(&audio_path) { - eprintln!("Failed to play recording sound: {}", e); + eprintln!("Failed to play sound '{}': {}", resource_path, e); } }); } +/// Convenience function to play the recording start sound +pub fn play_recording_start_sound(app: &AppHandle) { + play_sound(app, "resources/rec_start.wav"); +} + +/// Convenience function to play the recording stop sound +pub fn play_recording_stop_sound(app: &AppHandle) { + play_sound(app, "resources/rec_stop.wav"); +} + fn play_audio_file(path: &std::path::Path) -> Result<(), Box> { // Get a output stream handle to the default physical sound device let (_stream, stream_handle) = OutputStream::try_default()?; diff --git a/src/components/settings/KeyboardShortcuts.tsx b/src/components/settings/KeyboardShortcuts.tsx index df5c967..6018431 100644 --- a/src/components/settings/KeyboardShortcuts.tsx +++ b/src/components/settings/KeyboardShortcuts.tsx @@ -15,7 +15,7 @@ export const KeyboardShortcuts: React.FC = () => { const [bindings, setBindings] = React.useState({}); const [pttEnabled, setPttEnabled] = React.useState(false); const [audioFeedbackEnabled, setAudioFeedbackEnabled] = - React.useState(true); + React.useState(false); const [keyPressed, setKeyPressed] = useState([]); const [recordedKeys, setRecordedKeys] = useState([]); const [editingShortcutId, setEditingShortcutId] = useState(