A free, open source, and extensible speech-to-text application that works completely offline.
fix: prevent model auto-switch from interrupting active transcription (#443)
Viren Mohindrab31a41ad2f63
diff --git a/src-tauri/src/commands/audio.rs b/src-tauri/src/commands/audio.rsindex 48209f41..1d135f5d 100644--- a/src-tauri/src/commands/audio.rs+++ b/src-tauri/src/commands/audio.rs@@ -193,3 +193,10 @@ pub fn get_clamshell_microphone(app: AppHandle) -> Result<String, String> {.clamshell_microphone.unwrap_or_else(|| "default".to_string()))}++#[tauri::command]+#[specta::specta]+pub fn is_recording(app: AppHandle) -> bool {+ let audio_manager = app.state::<Arc<AudioRecordingManager>>();+ audio_manager.is_recording()+}diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex ea9f85c8..d9e113d7 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -296,6 +296,7 @@ pub fn run() {commands::audio::check_custom_sounds,commands::audio::set_clamshell_microphone,commands::audio::get_clamshell_microphone,+ commands::audio::is_recording,commands::transcription::set_model_unload_timeout,commands::transcription::get_model_load_status,commands::transcription::unload_model_manually,diff --git a/src/bindings.ts b/src/bindings.tsindex 702dd2dd..cf72c49a 100644--- a/src/bindings.ts+++ b/src/bindings.ts@@ -517,6 +517,9 @@ async getClamshellMicrophone() : Promise<Result<string, string>> {else return { status: "error", error: e as any };}},+async isRecording() : Promise<boolean> {+ return await TAURI_INVOKE("is_recording");+},async setModelUnloadTimeout(timeout: ModelUnloadTimeout) : Promise<void> {await TAURI_INVOKE("set_model_unload_timeout", { timeout });},diff --git a/src/components/model-selector/ModelSelector.tsx b/src/components/model-selector/ModelSelector.tsxindex 3d527f42..cb4627b6 100644--- a/src/components/model-selector/ModelSelector.tsx+++ b/src/components/model-selector/ModelSelector.tsx@@ -164,8 +164,12 @@ const ModelSelector: React.FC<ModelSelectorProps> = ({ onError }) => {});loadModels(); // Refresh models list- // Auto-select the newly downloaded model- setTimeout(() => {+ // Auto-select the newly downloaded model (skip if recording in progress)+ setTimeout(async () => {+ const recordingResult = await commands.isRecording();+ if (recordingResult.status === "ok" && recordingResult.data) {+ return; // Skip auto-switch if recording in progress+ }loadCurrentModel();handleModelSelect(modelId);}, 500);@@ -193,8 +197,12 @@ const ModelSelector: React.FC<ModelSelectorProps> = ({ onError }) => {});loadModels(); // Refresh models list- // Auto-select the newly extracted model- setTimeout(() => {+ // Auto-select the newly extracted model (skip if recording in progress)+ setTimeout(async () => {+ const recordingResult = await commands.isRecording();+ if (recordingResult.status === "ok" && recordingResult.data) {+ return; // Skip auto-switch if recording in progress+ }loadCurrentModel();handleModelSelect(modelId);}, 500);