generated from nhcarrigan/template
feat: template
This commit is contained in:
+27
-2
@@ -316,15 +316,40 @@ fn start_recording(
|
||||
Ok("Recording started".to_string())
|
||||
}
|
||||
|
||||
/// Stop recording and return the transcript.
|
||||
/// Stop recording (for real-time mode, transcription already happened during recording).
|
||||
#[tauri::command]
|
||||
async fn stop_recording(
|
||||
state: State<'_, AppState>,
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> Result<String, String> {
|
||||
let logs = Arc::clone(&state.logs);
|
||||
|
||||
emit_log(&app_handle, &logs, "[Audio] Stopping recording...");
|
||||
|
||||
// Stop the recording and get the duration
|
||||
let duration = {
|
||||
let mut audio_guard = state.audio_capture.lock();
|
||||
if let Some(ref mut capture) = *audio_guard {
|
||||
let samples = capture.stop_recording();
|
||||
samples.len() as f32 / 16000.0
|
||||
} else {
|
||||
return Err("No active recording".to_string());
|
||||
}
|
||||
};
|
||||
|
||||
emit_log(&app_handle, &logs, &format!("[Audio] Recording stopped. Total duration: {:.1}s", duration));
|
||||
Ok("Recording stopped".to_string())
|
||||
}
|
||||
|
||||
/// Stop recording and transcribe all at once (batch mode).
|
||||
#[tauri::command]
|
||||
async fn stop_recording_batch(
|
||||
state: State<'_, AppState>,
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> Result<Vec<TranscriptSegment>, String> {
|
||||
let logs = Arc::clone(&state.logs);
|
||||
|
||||
emit_log(&app_handle, &logs, "[Audio] Stopping recording...");
|
||||
emit_log(&app_handle, &logs, "[Audio] Stopping recording (batch mode)...");
|
||||
|
||||
// Get the audio samples
|
||||
let audio_samples = {
|
||||
|
||||
Reference in New Issue
Block a user