pub struct Recognizer { /* private fields */ }
Expand description
Google Speech API recognizer
Implementations
sourceimpl Recognizer
impl Recognizer
sourcepub async fn create_streaming_recognizer(
google_credentials: impl AsRef<str>,
config: StreamingRecognitionConfig,
buffer_size: Option<usize>
) -> Result<Self>
pub async fn create_streaming_recognizer(
google_credentials: impl AsRef<str>,
config: StreamingRecognitionConfig,
buffer_size: Option<usize>
) -> Result<Self>
Creates new speech recognizer from provided Google credentials and google speech configuration. This kind of recognizer can be used for streaming recognition.
sourcepub async fn create_asynchronous_recognizer(
google_credentials: impl AsRef<str>
) -> Result<Self>
pub async fn create_asynchronous_recognizer(
google_credentials: impl AsRef<str>
) -> Result<Self>
Creates new speech recognizer from provided Google credentials. This kind of recognizer can be used for long running recognition.
sourcepub async fn create_synchronous_recognizer(
google_credentials: impl AsRef<str>
) -> Result<Self>
pub async fn create_synchronous_recognizer(
google_credentials: impl AsRef<str>
) -> Result<Self>
Creates new speech recognizer from provided Google credentials. This kind of recognizer can be used for synchronous recognition.
sourcepub fn get_audio_sink(&mut self) -> Option<Sender<StreamingRecognizeRequest>>
pub fn get_audio_sink(&mut self) -> Option<Sender<StreamingRecognizeRequest>>
Returns sender than can be used to stream in audio bytes. This method can be called multiple times to retrieve multiple senders.
sourcepub fn take_audio_sink(&mut self) -> Option<Sender<StreamingRecognizeRequest>>
pub fn take_audio_sink(&mut self) -> Option<Sender<StreamingRecognizeRequest>>
Returns sender than can be used to stream in audio bytes. This method will take the sender out of the option leaving None in its place. No additional sender can be retrieved from recognizer after this call. When sender is dropped respective stream will be closed.
sourcepub fn drop_audio_sink(&mut self)
pub fn drop_audio_sink(&mut self)
Drops audio sender so that respective stream can be closed.
sourcepub fn get_streaming_result_receiver(
&mut self,
buffer_size: Option<usize>
) -> Receiver<StreamingRecognizeResponse>
pub fn get_streaming_result_receiver(
&mut self,
buffer_size: Option<usize>
) -> Receiver<StreamingRecognizeResponse>
Returns receiver that can be used to receive speech-to-text results used with streaming_recognize function.
sourcepub fn streaming_request_from_bytes(
audio_bytes: Vec<u8>
) -> StreamingRecognizeRequest
pub fn streaming_request_from_bytes(
audio_bytes: Vec<u8>
) -> StreamingRecognizeRequest
Convenience function so that client does not have to create full StreamingRecognizeRequest and can just pass audio bytes vector instead.
sourcepub async fn streaming_recognize_async_stream(
&mut self
) -> impl Stream<Item = Result<StreamingRecognizeResponse>> + '_
pub async fn streaming_recognize_async_stream(
&mut self
) -> impl Stream<Item = Result<StreamingRecognizeResponse>> + '_
Initiates bidirectional streaming. Returns asynchronous stream of streaming recognition results Audio data must be fed into recognizer via channel sender returned by function get_audio_sink.
sourcepub async fn streaming_recognize(&mut self) -> Result<()>
pub async fn streaming_recognize(&mut self) -> Result<()>
Initiates bidirectional streaming. This call should be spawned into separate tokio task. Results can be then retrieved via channel receiver returned by method get_streaming_result_receiver.
sourcepub async fn long_running_recognize(
&mut self,
request: LongRunningRecognizeRequest
) -> Result<GrpcResponse<Operation>>
pub async fn long_running_recognize(
&mut self,
request: LongRunningRecognizeRequest
) -> Result<GrpcResponse<Operation>>
Initiates asynchronous recognition. Returns long running operation representing asynchronous computation performed by Google Cloud Platform. Use long_running_wait to wait until operation is done.
sourcepub async fn long_running_wait(
&mut self,
operation: Operation,
check_interval_ms: Option<u64>
) -> Result<Option<LongRunningRecognizeResponse>>
pub async fn long_running_wait(
&mut self,
operation: Operation,
check_interval_ms: Option<u64>
) -> Result<Option<LongRunningRecognizeResponse>>
Waits for completion of long running operation returned by long_running_recognize function. Long running operation result is then casted into LongRunningRecognizeResponse struct. Function checks operation status regularly using get_operation which is called every check_interval_ms ms. If check_interval_ms is not specified default interval check is 1 sec.
sourcepub async fn recognize(
&mut self,
request: RecognizeRequest
) -> Result<RecognizeResponse>
pub async fn recognize(
&mut self,
request: RecognizeRequest
) -> Result<RecognizeResponse>
Performs synchronous speech recognition.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Recognizer
impl Send for Recognizer
impl Sync for Recognizer
impl Unpin for Recognizer
impl !UnwindSafe for Recognizer
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request