pub struct AudioToTextRequest<N, S = StreamOff>where
N: AudioToText,
S: StreamState,{ /* private fields */ }Expand description
Type-state request builder for speech-to-text transcription.
Exactly one input must be configured with
with_file_path or
with_file_base64. Non-streaming requests use
send_via; enable_stream
switches the builder to the streaming-only stream_via
API.
Implementations§
Source§impl<N> AudioToTextRequest<N, StreamOff>where
N: AudioToText,
impl<N> AudioToTextRequest<N, StreamOff>where
N: AudioToText,
Sourcepub fn enable_stream(self) -> AudioToTextRequest<N, StreamOn>
pub fn enable_stream(self) -> AudioToTextRequest<N, StreamOn>
Switch to the typed SSE response API and serialize stream=true.
Sourcepub async fn send_via(
&self,
client: &ZaiClient,
) -> ZaiResult<AudioToTextResponse>
pub async fn send_via( &self, client: &ZaiClient, ) -> ZaiResult<AudioToTextResponse>
Submit a non-streaming request and decode its required response fields.
Source§impl<N> AudioToTextRequest<N, StreamOn>where
N: AudioToText,
impl<N> AudioToTextRequest<N, StreamOn>where
N: AudioToText,
Sourcepub fn disable_stream(self) -> AudioToTextRequest<N, StreamOff>
pub fn disable_stream(self) -> AudioToTextRequest<N, StreamOff>
Return to the non-streaming response API and serialize stream=false.
Sourcepub async fn stream_via(
&self,
client: &ZaiClient,
) -> ZaiResult<SpeechToTextStream>
pub async fn stream_via( &self, client: &ZaiClient, ) -> ZaiResult<SpeechToTextStream>
Submit the multipart request and decode typed transcription SSE events.
The streaming POST is never retried or redirected. A missing [DONE],
malformed event, in-band business error, oversized event, or idle
timeout is returned once and then terminates the stream.
Source§impl<N, S> AudioToTextRequest<N, S>where
N: AudioToText,
S: StreamState,
impl<N, S> AudioToTextRequest<N, S>where
N: AudioToText,
S: StreamState,
Sourcepub fn body(&self) -> &AudioToTextBody<N>
pub fn body(&self) -> &AudioToTextBody<N>
Borrow the multipart metadata body.
Sourcepub fn has_file_base64(&self) -> bool
pub fn has_file_base64(&self) -> bool
Whether a base64 input is configured.
The encoded audio itself is intentionally not exposed by an accessor or
by Debug output.
Sourcepub fn with_file_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_file_path(self, path: impl Into<PathBuf>) -> Self
Select a local WAV or MP3 file. Supplying base64 as well is an error; setters do not silently override one another.
Sourcepub fn with_file_base64(self, encoded: impl Into<String>) -> Self
pub fn with_file_base64(self, encoded: impl Into<String>) -> Self
Select standard-base64 encoded WAV or MP3 bytes. Supplying a local file as well is an error.
Sourcepub fn with_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_prompt(self, prompt: impl Into<String>) -> Self
Set optional prior-transcript context. The upstream 8,000-character recommendation remains advisory and is not hard-rejected by the SDK.
Sourcepub fn with_hotwords(self, hotwords: Vec<String>) -> ZaiResult<Self>
pub fn with_hotwords(self, hotwords: Vec<String>) -> ZaiResult<Self>
Set at most 100 non-blank hot words.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Set the client request identifier (6..=64 characters).
Sourcepub fn with_user_id(self, user_id: impl Into<String>) -> Self
pub fn with_user_id(self, user_id: impl Into<String>) -> Self
Set the end-user identifier (6..=128 characters).