pub struct SpeechRecognizer { /* private fields */ }
Expand description
SpeechRecognizer struct holds functionality for speech-to-text recognition.
Implementations
sourceimpl SpeechRecognizer
impl SpeechRecognizer
pub fn from_config(
speech_config: SpeechConfig,
audio_config: AudioConfig
) -> Result<SpeechRecognizer>
pub fn from_embedded_config(
speech_config: EmbeddedSpeechConfig,
audio_config: AudioConfig
) -> Result<SpeechRecognizer>
pub fn from_auto_detect_source_lang_config(
speech_config: SpeechConfig,
audio_config: AudioConfig,
lang_config: AutoDetectSourceLanguageConfig
) -> Result<SpeechRecognizer>
pub fn from_source_lang_config(
speech_config: SpeechConfig,
audio_config: AudioConfig,
source_lang_config: SourceLanguageConfig
) -> Result<SpeechRecognizer>
pub fn from_source_lang(
speech_config: SpeechConfig,
audio_config: AudioConfig,
source_lang: &str
) -> Result<SpeechRecognizer>
pub fn set_session_started_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(SessionEvent) + 'static + Send,
pub fn set_session_stopped_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(SessionEvent) + 'static + Send,
pub fn set_speech_start_detected_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(RecognitionEvent) + 'static + Send,
pub fn set_speech_end_detected_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(RecognitionEvent) + 'static + Send,
sourcepub fn set_canceled_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(SpeechRecognitionCanceledEvent) + 'static + Send,
pub fn set_canceled_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(SpeechRecognitionCanceledEvent) + 'static + Send,
Canceled signals for events containing canceled recognition results (indicating a recognition attempt that was canceled as a result or a direct cancellation request or, alternatively, a transport or protocol failure).
pub fn set_recognizing_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(SpeechRecognitionEvent) + 'static + Send,
pub fn set_recognized_cb<F>(&mut self, f: F) -> Result<()> where
F: Fn(SpeechRecognitionEvent) + 'static + Send,
sourcepub async fn recognize_once_async(&mut self) -> Result<SpeechRecognitionResult>
pub async fn recognize_once_async(&mut self) -> Result<SpeechRecognitionResult>
Starts speech recognition, and returns after a single utterance is recognized. The end of a single utterance is determined by listening for silence at the end or until a maximum of 15 seconds of audio is processed. The task returns the recognition text as result. Note: Since RecognizeOnceAsync() returns only a single utterance, it is suitable only for single shot recognition like command or query. For long-running multi-utterance recognition, use StartContinuousRecognitionAsync() instead.
sourcepub async fn start_continuous_recognition_async(&mut self) -> Result<()>
pub async fn start_continuous_recognition_async(&mut self) -> Result<()>
Asynchronously initiates continuous speech recognition operation.
sourcepub async fn stop_continuous_recognition_async(&mut self) -> Result<()>
pub async fn stop_continuous_recognition_async(&mut self) -> Result<()>
Asynchronously terminates ongoing continuous speech recognition operation.
sourcepub async fn start_keyword_recognition_async(
&mut self,
model: KeywordRecognitionModel
) -> Result<()>
pub async fn start_keyword_recognition_async(
&mut self,
model: KeywordRecognitionModel
) -> Result<()>
Asynchronously initiates keyword recognition operation.
sourcepub async fn stop_keyword_recognition_async(&mut self) -> Result<()>
pub async fn stop_keyword_recognition_async(&mut self) -> Result<()>
Asynchronously terminates keyword recognition operation.
pub fn get_endpoint_id(&self) -> Result<String>
pub fn get_auth_token(&self) -> Result<String>
sourcepub fn set_auth_token(&mut self, token: &str) -> Result<()>
pub fn set_auth_token(&mut self, token: &str) -> Result<()>
Sets the authorization token that will be used for connecting to the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the recognizer will encounter errors during recognition.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for SpeechRecognizer
impl Send for SpeechRecognizer
impl !Sync for SpeechRecognizer
impl Unpin for SpeechRecognizer
impl !UnwindSafe for SpeechRecognizer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more