aristech-stt-client

Crates.ioaristech-stt-client
lib.rsaristech-stt-client
version3.1.2
created_at2024-10-21 11:47:15.760913+00
updated_at2025-08-25 06:40:20.095118+00
descriptionA Rust client library for the Aristech Speech-to-Text API
homepagehttps://github.com/aristech-de/stt-clients/blob/main/rust/README.md
repositoryhttps://github.com/aristech-de/stt-clients
max_upload_size
id1417299
size104,904
Martin Mende (mmende)

documentation

README

Aristech STT-Client for Rust

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

Installation

To use the client in your project, add it to your Cargo.toml or use cargo to add it:

cargo add aristech-stt-client

Usage

use aristech_stt_client::{SttClientBuilder, recognize_file};
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    // Creating a client like this will attempt to parse the API key from the environment variable `ARISTECH_STT_API_KEY`
    // but won't fail if it is not present or invalid.
    let mut client = SttClientBuilder::new()
        .build()
        .await?;

    // To manually specify the API key and catch invalid API keys, use the default builder and the `api_key` method.
    // let mut client = SttClientBuilder::default() // <- won't attempt to parse the API key from the environment variable
    //     .api_key("at-abc123...")?
    //     .build()
    //     .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.

To run the examples, use cargo. For example:

cargo run --example live

API Key

If you didn't get an API key but a token, secret and host instead, you can simply convert those values with our API key generator.

Alternatively you can still provide the connection options manually.
use aristech_stt_client::{SttClientBuilder, Auth};

let mut client = SttClientBuilder::default()
    .host("https://stt.example.com:443")?
    .auth(Some(Auth {
        token: "your-token".to_string(),
        secret: "your-secret".to_string(),
    }))
    .build()
    .await?;

Build

To build the library, run:

cargo build
Commit count: 72

cargo fmt