Skip to content

Commit 9a3662b

Browse files
Fix cross-platform Whisper capture compilation
1 parent ffe1408 commit 9a3662b

3 files changed

Lines changed: 17 additions & 15 deletions

File tree

crates/wisp-audiokit/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3741,7 +3741,7 @@ mod imp {
37413741
use crate::{
37423742
CallbackEventClass, CallbackEventReceiver, CallbackEventSender, MergedSessionReceive,
37433743
OneShotSessionLifecycle, Permission, PermissionStatus, SessionConfig, SessionOptions,
3744-
TranscriptionPolicy, WasapiRecording, WhisperTranscriberBackend, WindowsPlatformStart,
3744+
TranscriptionPolicy, WasapiRecording, WhisperTranscriberFactory, WindowsPlatformStart,
37453745
WindowsPlatformStartError, WindowsRuntimeControlPublisher, WindowsRuntimeNotification,
37463746
WindowsTranscriptionMode, callback_event_channel_with_final_gap,
37473747
recv_callback_session_channels_with_control, select_windows_transcription_mode,

crates/wisp-audiokit/src/pipewire_capture.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -863,13 +863,14 @@ fn recording_loop_with_transcriber(
863863
let mut mic_timeline = TrackTimeline::default();
864864
let mut system_timeline = TrackTimeline::default();
865865
while let Some(event) = receiver.recv() {
866-
if let Some(transcriber) = transcriber.as_deref_mut() {
867-
if let Err(error) = transcriber.push_capture(&event) {
868-
let _ = notifications.try_send(format!(
869-
"Whisper transcription stopped ({error}); audio recording continues"
870-
));
871-
transcriber = None;
872-
}
866+
let transcription_error = transcriber
867+
.as_deref_mut()
868+
.and_then(|active| active.push_capture(&event).err());
869+
if let Some(error) = transcription_error {
870+
let _ = notifications.try_send(format!(
871+
"Whisper transcription stopped ({error}); audio recording continues"
872+
));
873+
transcriber = None;
873874
}
874875
match event {
875876
CaptureEvent::Samples(frame) => {

crates/wisp-audiokit/src/wasapi_capture.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,13 +1041,14 @@ fn recording_loop(
10411041
let mut system_timeline = TrackTimeline::default();
10421042
let processing_result = (|| {
10431043
while let Some(event) = receiver.recv() {
1044-
if let Some(transcriber) = transcriber.as_deref_mut() {
1045-
if let Err(error) = transcriber.push_capture(&event) {
1046-
let _ = notification_sender.try_send(RecordingNotification::Warning(format!(
1047-
"Whisper transcription stopped ({error}); audio recording continues"
1048-
)));
1049-
transcriber = None;
1050-
}
1044+
let transcription_error = transcriber
1045+
.as_deref_mut()
1046+
.and_then(|active| active.push_capture(&event).err());
1047+
if let Some(error) = transcription_error {
1048+
let _ = notification_sender.try_send(RecordingNotification::Warning(format!(
1049+
"Whisper transcription stopped ({error}); audio recording continues"
1050+
)));
1051+
transcriber = None;
10511052
}
10521053
match event {
10531054
CaptureEvent::Samples(frame) => {

0 commit comments

Comments
 (0)