#speech-recognition #real-time #streaming #client-library #api-bindings

aristech-stt-client

A Rust client library for the Aristech Speech-to-Text API

2 stable releases

new 2.0.0 Oct 23, 2024
1.0.0 Oct 21, 2024

#476 in Audio

Download history 106/week @ 2024-10-16

106 downloads per month

MIT license

26KB
188 lines

Aristech STT-Client for Rust

This is the Rust client implementation for the Aristech STT-Server.

Installation

Add the following to your Cargo.toml:

[dependencies]
aristech_stt_client = "2.0.0"

Usage

use aristech_stt_client::{get_client, recognize_file, TlsOptions, Auth};
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut client = get_client(
    "https://stt.example.com",
    Some(TlsOptions {
        ca_certificate: None,
        auth: Some(Auth { token: "your-token", secret: "your-secret" }),
    }),
    ).await?;

    let results = recognize_file(&mut client, "path/to/audio/file.wav", None).await?;
    for result in results {
        println!(
            "{}",
            result
                .chunks
                .get(0)
                .unwrap()
                .alternatives
                .get(0)
                .unwrap()
                .text
        );
    }
    Ok(())
}

There are several examples in the examples directory:

  • file.rs: Demonstrates how to perform recognition on a file.
  • live.rs: Demonstrates how to perform live recognition using the microphone.
  • models.rs: Demonstrates how to get the available models from the server.
  • nlpFunctions.rs: Demonstrates how to list the configured NLP-Servers and the coresponding functions.
  • nlpProcess.rs: Demonstrates how to perform NLP processing on a text by using the STT-Server as a proxy.
  • account.rs: Demonstrates how to retrieve the account information from the server.

You can run the examples directly using cargo like this:

  1. Create a .env file in the rust directory:
HOST=https://stt.example.com # Note: The protocol is required in the rust client
# The credentials are optional but probably required for most servers:
TOKEN=your-token
SECRET=your-secret

# The following are optional:
# ROOT_CERT=your-root-cert.pem # If the server uses a self-signed certificate
# SSL=true # Set to true if credentials are provided or if a ROOT_CERT is provided
# MODEL=some-available-model
# NLP_SERVER=some-config
# NLP_PIPELINE=function1,function2
  1. Run the examples, e.g.:
cargo run --example live

Build

To build the library, run:

cargo build

Dependencies

~13–43MB
~769K SLoC