11//! Realtime transcription session helpers for Pass1 streaming.
22
3- #[ cfg( all( target_os = "macos" , feature = "voxit-realtime" ) ) ] use std:: time:: Duration ;
43use std:: {
54 fmt:: { Display , Formatter } ,
6- sync:: {
7- mpsc,
8- mpsc:: { Receiver , Sender } ,
9- } ,
10- thread:: { self , JoinHandle } ,
5+ sync:: mpsc:: { Receiver , Sender } ,
6+ thread:: JoinHandle ,
117} ;
8+ #[ cfg( feature = "voxit-realtime" ) ] use std:: { sync:: mpsc, thread, time:: Duration } ;
129
1310use base64:: { Engine , engine:: general_purpose:: STANDARD } ;
14- #[ cfg( all( target_os = "macos" , feature = "voxit-realtime" ) ) ]
15- use futures_util:: { SinkExt as _, StreamExt as _} ;
16- use http:: Request ;
11+ #[ cfg( feature = "voxit-realtime" ) ] use futures_util:: { SinkExt as _, StreamExt as _} ;
12+ #[ cfg( feature = "voxit-realtime" ) ] use http:: Request ;
1713use serde_json:: Value ;
18- #[ cfg( all( target_os = "macos" , feature = "voxit-realtime" ) ) ] use tokio:: runtime:: Runtime ;
19- use tokio:: time;
20- #[ cfg( all( target_os = "macos" , feature = "voxit-realtime" ) ) ]
21- use tokio_tungstenite:: tungstenite:: protocol:: Message ;
14+ #[ cfg( feature = "voxit-realtime" ) ] use tokio:: { runtime:: Runtime , time} ;
15+ #[ cfg( feature = "voxit-realtime" ) ] use tokio_tungstenite:: tungstenite:: protocol:: Message ;
2216
2317use crate :: transcript:: TranscriptEvent ;
2418use voxit_audio:: AudioChunk ;
@@ -82,7 +76,7 @@ pub enum RealtimeEvent {
8276#[ derive( Clone , Debug ) ]
8377pub enum RealtimeError {
8478 /// Required websocket client feature is not enabled for this build.
85- #[ cfg( not( all ( target_os = "macos" , feature = "voxit-realtime" ) ) ) ]
79+ #[ cfg( not( feature = "voxit-realtime" ) ) ]
8680 DependencyUnavailable {
8781 /// Human-readable reason.
8882 reason : String ,
@@ -97,15 +91,15 @@ impl Display for RealtimeError {
9791 /// Format error to string.
9892 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
9993 match self {
100- #[ cfg( not( all ( target_os = "macos" , feature = "voxit-realtime" ) ) ) ]
94+ #[ cfg( not( feature = "voxit-realtime" ) ) ]
10195 Self :: DependencyUnavailable { reason } => write ! ( f, "{reason}" ) ,
10296 Self :: RuntimeError { reason } => write ! ( f, "{reason}" ) ,
10397 }
10498 }
10599}
106100
107101/// Start a Pass1 websocket session and stream chunks to OpenAI Realtime.
108- #[ cfg( all ( target_os = "macos" , feature = "voxit-realtime" ) ) ]
102+ #[ cfg( feature = "voxit-realtime" ) ]
109103pub fn start_realtime_session (
110104 api_key : String ,
111105 account_id : Option < String > ,
@@ -117,7 +111,7 @@ pub fn start_realtime_session(
117111}
118112
119113/// Start a Pass1 websocket session and stream chunks to OpenAI Realtime.
120- #[ cfg( not( all ( target_os = "macos" , feature = "voxit-realtime" ) ) ) ]
114+ #[ cfg( not( feature = "voxit-realtime" ) ) ]
121115pub fn start_realtime_session (
122116 api_key : String ,
123117 account_id : Option < String > ,
@@ -136,7 +130,7 @@ pub fn start_realtime_session(
136130 } )
137131}
138132
139- #[ cfg( all ( target_os = "macos" , feature = "voxit-realtime" ) ) ]
133+ #[ cfg( feature = "voxit-realtime" ) ]
140134fn start_realtime_session_impl (
141135 api_key : String ,
142136 account_id : Option < String > ,
@@ -152,7 +146,7 @@ fn start_realtime_session_impl(
152146 Ok ( RealtimeSession { stop_tx : Some ( stop_tx) , worker : Some ( worker) } )
153147}
154148
155- #[ cfg( all ( target_os = "macos" , feature = "voxit-realtime" ) ) ]
149+ #[ cfg( feature = "voxit-realtime" ) ]
156150fn run_realtime_worker (
157151 api_key : String ,
158152 account_id : Option < String > ,
0 commit comments