From 51f76947f560b4d491004e6d641eff6939c1b2f3 Mon Sep 17 00:00:00 2001 From: Max Novich Date: Fri, 20 Dec 2024 22:26:48 -0800 Subject: [PATCH] cargo fmt --- crates/goose-server/src/routes/transcribe.rs | 42 ++++++++++---------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/crates/goose-server/src/routes/transcribe.rs b/crates/goose-server/src/routes/transcribe.rs index 84e0c335f..c1cd0061e 100644 --- a/crates/goose-server/src/routes/transcribe.rs +++ b/crates/goose-server/src/routes/transcribe.rs @@ -52,7 +52,7 @@ async fn get_status() -> Arc> { async fn ensure_whisper() { INIT.get_or_init(|| async { let status = get_status().await; - + // Get the project root directory let mut project_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); project_dir.pop(); // go up from goose-server @@ -118,7 +118,7 @@ async fn check_whisper_ready() -> Result<(), (StatusCode, Json Result<(), (StatusCode, Json Result, (StatusCode, Json)> { +async fn transcribe( + mut multipart: Multipart, +) -> Result, (StatusCode, Json)> { // Check if whisper is ready check_whisper_ready().await?; @@ -155,7 +157,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": "Received empty audio data" - })) + })), )); } @@ -169,7 +171,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Failed to create temporary WebM file: {}", e) - })) + })), )); } }; @@ -184,7 +186,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Failed to create temporary WAV file: {}", e) - })) + })), )); } }; @@ -200,7 +202,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Failed to write WebM data: {}", e) - })) + })), )); } } @@ -236,7 +238,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": "Whisper executable not found" - })) + })), )); } @@ -248,7 +250,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": "Whisper model not found" - })) + })), )); } @@ -262,7 +264,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Failed to verify WebM file: {}", e) - })) + })), )); } }; @@ -293,7 +295,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Invalid WebM file: {}", String::from_utf8_lossy(&ffprobe_webm.stderr)) - })) + })), )); } @@ -330,7 +332,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("FFmpeg conversion failed: {}", String::from_utf8_lossy(&ffmpeg_output.stderr)) - })) + })), )); } @@ -344,7 +346,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Failed to verify WAV file: {}", e) - })) + })), )); } }; @@ -358,7 +360,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": "WAV conversion failed - output file is empty" - })) + })), )); } @@ -387,7 +389,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Invalid WAV file: {}", String::from_utf8_lossy(&ffprobe_wav.stderr)) - })) + })), )); } @@ -440,7 +442,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Failed to read transcription output: {}", e) - })) + })), )); } } @@ -456,7 +458,7 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": format!("Whisper failed: {}", String::from_utf8_lossy(&output.stderr)) - })) + })), )); } } else { @@ -470,6 +472,6 @@ async fn transcribe(mut multipart: Multipart) -> Result, Json(json!({ "success": false, "error": "Failed to process audio" - })) + })), )) -} \ No newline at end of file +}