Module recognizer

Source
Expand description

Speech to text module.

This module provides functionality to convert speech to text using Azure Speech Services.

§Example

use std::env;
use std::path::Path;
use tokio::fs::File;
use tokio::io::{AsyncReadExt, BufReader};

use azure_speech::Auth;
use azure_speech::recognizer;
use azure_speech::stream::{Stream, StreamExt,wrappers::ReceiverStream};

#[tokio::main]
async fn main() -> azure_speech::Result<()> {

    let auth = Auth::from_subscription(
        env::var("AZURE_REGION").expect("Region set on AZURE_REGION env"),
        env::var("AZURE_SUBSCRIPTION_KEY").expect("Subscription set on AZURE_SUBSCRIPTION_KEY env"),
    );

    let client = recognizer::Client::connect(auth, recognizer::Config::default()).await?;

    // check in the example folder for how to create the audio stream.
    let audio_stream = create_audio_stream();
    let mut stream = client
        .recognize(audio_stream, recognizer::ContentType::Mp3, recognizer::Details::file())
        .await?;

    while let Some(event) = stream.next().await {
        tracing::info!("Event: {:?}", event);
    }

    tracing::info!("Completed!");

    Ok(())
}

Structs§

AudioDevice
Details of the source.
Callback
Client
Config
The configuration for the recognizer.
PrimaryLanguage
Primary language
Recognized
The recognized text.
Silence
The configuration for the silence detection.

Enums§

AudioFormat
The Audio Format of the audio data.
Confidence
The confidence of the speech recognition.
ConnectionType
Event
Recognizer events.
Language
Language that the recognizer should recognize.
LanguageDetectMode
The primary language of the recognized text.
OutputFormat
The output format of the messages.
Profanity
The profanity level.
RecognitionMode
The recognition mode.
SourceType

Type Aliases§

Duration
The duration of the speech recognition.
Offset
The offset of the speech recognition.
RawMessage
The raw text of message.