mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-30 10:52:15 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2dcd05227a
commit
e4ed38edd3
@@ -167,6 +167,50 @@ async fn run_jarvis_command(args: Vec<String>) -> Result<String, String> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Transcribe audio via the speech API endpoint.
|
||||
#[tauri::command]
|
||||
async fn transcribe_audio(
|
||||
api_url: String,
|
||||
audio_data: Vec<u8>,
|
||||
filename: String,
|
||||
) -> Result<serde_json::Value, String> {
|
||||
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<serde_json::Value, String> {
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user