pub struct SttStream { /* private fields */ }Expand description
A streaming STT session for real-time audio transcription.
This struct maintains an active WebSocket connection to the STT service and provides methods to send audio data and receive transcription results.
Implementations§
Source§impl SttStream
impl SttStream
pub fn split(self) -> (SttStreamSender, SttStreamReceiver)
Sourcepub async fn new(setup: Setup, client: &Client) -> Result<Self>
pub async fn new(setup: Setup, client: &Client) -> Result<Self>
Creates a new STT streaming session.
This establishes a WebSocket connection to the STT service, sends the setup configuration, and waits for the server’s Ready response.
§Arguments
setup- Configuration for the STT session (model name, audio format)client- The Gradium client to use for the connection
§Returns
A new SttStream ready to accept audio data
§Errors
Returns an error if:
- The WebSocket connection fails
- The server responds with an error
- The server sends an unexpected response
Sourcepub async fn send_eos(&mut self) -> Result<()>
pub async fn send_eos(&mut self) -> Result<()>
Signals the end of the audio stream.
This tells the server that no more audio will be sent, allowing it to finalize the transcription and send any remaining results.
§Errors
Returns an error if the message cannot be sent
pub async fn send_audio_base64(&mut self, audio_b64: String) -> Result<()>
Sourcepub async fn next_message(&mut self) -> Result<Option<Response>>
pub async fn next_message(&mut self) -> Result<Option<Response>>
Receives the next message from the server.
This method waits for and returns transcription results, VAD updates, or other server responses.
§Returns
Ok(Some(response))- A response from the serverOk(None)- The stream has ended (EndOfStream received or connection closed)Err(_)- An error occurred or the server sent an error response
§Errors
Returns an error if:
- The connection is closed unexpectedly
- The server sends an error response
- Message deserialization fails
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Returns the audio sample rate in Hz.
Sourcepub fn frame_size(&self) -> u32
pub fn frame_size(&self) -> u32
Returns the audio frame size in samples.
Sourcepub fn text_stream_names(&self) -> &[String]
pub fn text_stream_names(&self) -> &[String]
Returns the names of available text streams.
Sourcepub fn request_id(&self) -> &str
pub fn request_id(&self) -> &str
Returns the request ID for this session.