From e4ed38edd3144d81c4eff017e2f24a105e2ae46e Mon Sep 17 00:00:00 2001 From: Jon Saad-Falcon Date: Tue, 3 Mar 2026 20:00:27 +0000 Subject: [PATCH] feat(speech): add Tauri transcribe_audio and speech_health commands Proxies multipart audio upload and health check to the Python backend for the desktop app's speech-to-text integration. Co-Authored-By: Claude Opus 4.6 --- desktop/src-tauri/src/lib.rs | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index 55dba784..b9cde488 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -167,6 +167,50 @@ async fn run_jarvis_command(args: Vec) -> Result { } } +/// Transcribe audio via the speech API endpoint. +#[tauri::command] +async fn transcribe_audio( + api_url: String, + audio_data: Vec, + filename: String, +) -> Result { + let url = format!("{}/v1/speech/transcribe", api_url); + let client = reqwest::Client::new(); + + let part = reqwest::multipart::Part::bytes(audio_data) + .file_name(filename) + .mime_str("audio/webm") + .map_err(|e| format!("Failed to create multipart: {}", e))?; + + let form = reqwest::multipart::Form::new().part("file", part); + + let resp = client + .post(&url) + .multipart(form) + .send() + .await + .map_err(|e| format!("Connection failed: {}", e))?; + let body: serde_json::Value = resp + .json() + .await + .map_err(|e| format!("Invalid response: {}", e))?; + Ok(body) +} + +/// Check speech backend health. +#[tauri::command] +async fn speech_health(api_url: String) -> Result { + let url = format!("{}/v1/speech/health", api_url); + let resp = reqwest::get(&url) + .await + .map_err(|e| format!("Connection failed: {}", e))?; + let body: serde_json::Value = resp + .json() + .await + .map_err(|e| format!("Invalid response: {}", e))?; + Ok(body) +} + #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() @@ -240,6 +284,8 @@ pub fn run() { search_memory, fetch_agents, run_jarvis_command, + transcribe_audio, + speech_health, ]) .run(tauri::generate_context!()) .expect("error while running OpenJarvis Desktop");