| Crates.io | aristech-stt-client |
| lib.rs | aristech-stt-client |
| version | 3.1.2 |
| created_at | 2024-10-21 11:47:15.760913+00 |
| updated_at | 2025-08-25 06:40:20.095118+00 |
| description | A Rust client library for the Aristech Speech-to-Text API |
| homepage | https://github.com/aristech-de/stt-clients/blob/main/rust/README.md |
| repository | https://github.com/aristech-de/stt-clients |
| max_upload_size | |
| id | 1417299 |
| size | 104,904 |
This is the Rust client implementation for the Aristech STT-Server.
To use the client in your project, add it to your Cargo.toml or use cargo to add it:
cargo add aristech-stt-client
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
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.
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?;
To build the library, run:
cargo build