pub struct GeminiStt { /* private fields */ }Available on crate feature
audio only.Expand description
Gemini STT provider using generateContent with audio input.
Sends audio as inline data to the Gemini API and receives a text transcription. Supports language detection and optional prompting for specialized transcription tasks.
§Example
ⓘ
use adk_audio::{GeminiStt, SttProvider, SttOptions, AudioFrame};
let stt = GeminiStt::from_env()?;
let transcript = stt.transcribe(&audio_frame, &SttOptions::default()).await?;
println!("Transcribed: {}", transcript.text);Implementations§
Source§impl GeminiStt
impl GeminiStt
Sourcepub fn from_env() -> Result<GeminiStt, AudioError>
Available on crate feature stt only.
pub fn from_env() -> Result<GeminiStt, AudioError>
stt only.Create from environment variable GEMINI_API_KEY or GOOGLE_API_KEY.
Sourcepub fn new(api_key: impl Into<String>) -> GeminiStt
Available on crate feature stt only.
pub fn new(api_key: impl Into<String>) -> GeminiStt
stt only.Create with an explicit API key.
Sourcepub fn with_model(self, model: impl Into<String>) -> GeminiStt
Available on crate feature stt only.
pub fn with_model(self, model: impl Into<String>) -> GeminiStt
stt only.Set the model to use for transcription.
Sourcepub fn with_prompt(self, prompt: impl Into<String>) -> GeminiStt
Available on crate feature stt only.
pub fn with_prompt(self, prompt: impl Into<String>) -> GeminiStt
stt only.Set a custom transcription prompt.
The prompt is sent alongside the audio to guide the model’s output. For example: “Transcribe this audio in English with punctuation.”
Trait Implementations§
Source§impl SttProvider for GeminiStt
impl SttProvider for GeminiStt
Source§fn transcribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
audio: &'life1 AudioFrame,
opts: &'life2 SttOptions,
) -> Pin<Box<dyn Future<Output = Result<Transcript, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
GeminiStt: 'async_trait,
fn transcribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
audio: &'life1 AudioFrame,
opts: &'life2 SttOptions,
) -> Pin<Box<dyn Future<Output = Result<Transcript, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
GeminiStt: 'async_trait,
Transcribe a single audio frame (batch mode).
Source§fn transcribe_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
_audio: Pin<Box<dyn Stream<Item = AudioFrame> + Send>>,
_opts: &'life1 SttOptions,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Transcript, AudioError>> + Send>>, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GeminiStt: 'async_trait,
fn transcribe_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
_audio: Pin<Box<dyn Stream<Item = AudioFrame> + Send>>,
_opts: &'life1 SttOptions,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Transcript, AudioError>> + Send>>, AudioError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
GeminiStt: 'async_trait,
Transcribe a stream of audio frames (streaming mode).
Auto Trait Implementations§
impl Freeze for GeminiStt
impl !RefUnwindSafe for GeminiStt
impl Send for GeminiStt
impl Sync for GeminiStt
impl Unpin for GeminiStt
impl UnsafeUnpin for GeminiStt
impl !UnwindSafe for GeminiStt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more