generated from nhcarrigan/template
feat: display progress for finalising audio and summarising
This commit is contained in:
+18
-3
@@ -371,6 +371,7 @@ async fn stop_recording_batch(
|
||||
// Transcribe the audio
|
||||
emit_log(&app_handle, &logs, "[Transcribe] Starting transcription...");
|
||||
|
||||
let app_handle_clone = app_handle.clone();
|
||||
let mut segments = {
|
||||
let transcriber = state.transcriber.lock();
|
||||
if !transcriber.is_loaded() {
|
||||
@@ -378,7 +379,10 @@ async fn stop_recording_batch(
|
||||
return Err("Whisper model not loaded. Please ensure the model is downloaded.".to_string());
|
||||
}
|
||||
|
||||
transcriber.transcribe(&audio_samples)
|
||||
transcriber.transcribe_with_progress(&audio_samples, move |progress| {
|
||||
// Emit progress event to frontend
|
||||
let _ = app_handle_clone.emit("transcription-progress", progress);
|
||||
})
|
||||
.map_err(|e| format!("Transcription failed: {}", e))?
|
||||
};
|
||||
|
||||
@@ -399,6 +403,7 @@ async fn stop_recording_batch(
|
||||
async fn transcribe_chunk(
|
||||
state: State<'_, AppState>,
|
||||
audio_data: Vec<f32>,
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> Result<Vec<TranscriptSegment>, String> {
|
||||
let transcriber = state.transcriber.lock();
|
||||
|
||||
@@ -406,7 +411,13 @@ async fn transcribe_chunk(
|
||||
return Err("Whisper model not loaded".to_string());
|
||||
}
|
||||
|
||||
let segments = transcriber.transcribe(&audio_data)
|
||||
// Clone the app handle for the closure
|
||||
let app_handle_clone = app_handle.clone();
|
||||
|
||||
let segments = transcriber.transcribe_with_progress(&audio_data, move |progress| {
|
||||
// Emit progress event to frontend
|
||||
let _ = app_handle_clone.emit("transcription-progress", progress);
|
||||
})
|
||||
.map_err(|e| format!("Transcription failed: {}", e))?;
|
||||
|
||||
Ok(segments)
|
||||
@@ -460,7 +471,11 @@ async fn summarize(
|
||||
return Err("LLaMA model not loaded".to_string());
|
||||
}
|
||||
|
||||
let summary = summarizer.summarize(&transcript)
|
||||
let app_handle_clone = app_handle.clone();
|
||||
let summary = summarizer.summarize_with_progress(&transcript, move |progress| {
|
||||
// Emit progress event to frontend
|
||||
let _ = app_handle_clone.emit("summary-progress", progress);
|
||||
})
|
||||
.map_err(|e| format!("Summarization failed: {}", e))?;
|
||||
|
||||
emit_log(&app_handle, &logs, &format!("[Summary] Generated {} character summary", summary.len()));
|
||||
|
||||
Reference in New Issue
Block a user