pub struct SttFallbackChain { /* private fields */ }Expand description
Fallback chain for STT: local -> cloud on failure or low confidence.
Decision logic:
- Try local engine.
- If local succeeds with confidence >= threshold: return local result.
- If local succeeds with low confidence: try cloud, return whichever has higher confidence. On cloud error, return the local result.
- If local fails: try cloud. On cloud error too, propagate the local error (unless no cloud provider is configured).
Implementations§
Source§impl SttFallbackChain
impl SttFallbackChain
Sourcepub fn new(local: Box<dyn LocalSttEngine>) -> Self
pub fn new(local: Box<dyn LocalSttEngine>) -> Self
Create a new chain with only a local engine.
Sourcepub fn with_cloud(self, provider: Box<dyn CloudSttProvider>) -> Self
pub fn with_cloud(self, provider: Box<dyn CloudSttProvider>) -> Self
Add a cloud provider for fallback.
Sourcepub fn with_confidence_threshold(self, threshold: f32) -> Self
pub fn with_confidence_threshold(self, threshold: f32) -> Self
Override the confidence threshold (default: 0.60).
Sourcepub async fn transcribe(
&self,
audio_data: &[u8],
mime_type: &str,
language: Option<&str>,
) -> Result<SttFallbackResult, PluginError>
pub async fn transcribe( &self, audio_data: &[u8], mime_type: &str, language: Option<&str>, ) -> Result<SttFallbackResult, PluginError>
Transcribe audio, falling back to cloud if local fails or confidence is below the threshold.
Auto Trait Implementations§
impl Freeze for SttFallbackChain
impl !RefUnwindSafe for SttFallbackChain
impl Send for SttFallbackChain
impl Sync for SttFallbackChain
impl Unpin for SttFallbackChain
impl UnsafeUnpin for SttFallbackChain
impl !UnwindSafe for SttFallbackChain
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