pub struct LanguageDetection { /* private fields */ }Expand description
Language detection result (G2)
Provides detected language with confidence scores for alternatives.
§Example
use aprender::speech::asr::LanguageDetection;
let detection = LanguageDetection::new("en", 0.95)
.with_alternative("de", 0.03)
.with_alternative("fr", 0.02);
assert_eq!(detection.language(), "en");
assert!(detection.confidence() > 0.9);Implementations§
Source§impl LanguageDetection
impl LanguageDetection
Sourcepub fn new(language: impl Into<String>, confidence: f32) -> Self
pub fn new(language: impl Into<String>, confidence: f32) -> Self
Create a new language detection result
Sourcepub fn with_alternative(
self,
language: impl Into<String>,
confidence: f32,
) -> Self
pub fn with_alternative( self, language: impl Into<String>, confidence: f32, ) -> Self
Add an alternative language candidate
Sourcepub fn confidence(&self) -> f32
pub fn confidence(&self) -> f32
Get confidence score for the detected language
Sourcepub fn alternatives(&self) -> &[(String, f32)]
pub fn alternatives(&self) -> &[(String, f32)]
Get alternative language candidates
Sourcepub fn is_confident(&self, threshold: f32) -> bool
pub fn is_confident(&self, threshold: f32) -> bool
Check if detection is confident (> threshold)
Trait Implementations§
Source§impl Clone for LanguageDetection
impl Clone for LanguageDetection
Source§fn clone(&self) -> LanguageDetection
fn clone(&self) -> LanguageDetection
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LanguageDetection
impl Debug for LanguageDetection
Auto Trait Implementations§
impl Freeze for LanguageDetection
impl RefUnwindSafe for LanguageDetection
impl Send for LanguageDetection
impl Sync for LanguageDetection
impl Unpin for LanguageDetection
impl UnwindSafe for LanguageDetection
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more