generated from nhcarrigan/template
feat: handle transcription in real time
This commit is contained in:
@@ -387,6 +387,35 @@ async fn transcribe_chunk(
|
||||
Ok(segments)
|
||||
}
|
||||
|
||||
/// Get the next chunk of audio for real-time transcription.
|
||||
/// Returns the audio chunk and the new offset to use for the next call.
|
||||
#[tauri::command]
|
||||
async fn get_audio_chunk(
|
||||
state: State<'_, AppState>,
|
||||
last_offset: usize,
|
||||
) -> Result<(Vec<f32>, usize), String> {
|
||||
let audio_guard = state.audio_capture.lock();
|
||||
if let Some(ref capture) = *audio_guard {
|
||||
Ok(capture.extract_chunk(last_offset))
|
||||
} else {
|
||||
Err("No active recording".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// Get remaining audio without modifying the buffer (for final processing).
|
||||
#[tauri::command]
|
||||
async fn get_remaining_audio(
|
||||
state: State<'_, AppState>,
|
||||
last_offset: usize,
|
||||
) -> Result<Vec<f32>, String> {
|
||||
let audio_guard = state.audio_capture.lock();
|
||||
if let Some(ref capture) = *audio_guard {
|
||||
Ok(capture.get_remaining_audio(last_offset))
|
||||
} else {
|
||||
Err("No active recording".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a summary from a transcript.
|
||||
#[tauri::command]
|
||||
async fn summarize(
|
||||
@@ -449,6 +478,8 @@ pub fn run() {
|
||||
start_recording,
|
||||
stop_recording,
|
||||
transcribe_chunk,
|
||||
get_audio_chunk,
|
||||
get_remaining_audio,
|
||||
summarize,
|
||||
get_backend_logs,
|
||||
check_ready,
|
||||
|
||||
Reference in New Issue
Block a user