aic-sdk 0.24.0

ai-coustics SDK
Documentation
//! Example programs.
//!
//! You can run any of the examples with the following steps.
//!
//! Create a new empty directory. Change into it and run:
//!
//! ```bash
//! cargo init
//! ```
//!
//! Replace the contents of `src/main.rs` with the Rust code of the example you want to try.
//! Note that some examples have additional/different instructions,
//! but in most cases you should add the ai-coustics SDK with:
//!
//! ```bash
//! cargo add aic-sdk --features download-lib,download-model
//! ```
//!
//! The examples read the [license key](https://developers.ai-coustics.com/)
//! from the environment variable `AIC_SDK_LICENSE`, so you'll have to set that up:
//!
//! ```bash
//! export AIC_SDK_LICENSE="your_license_key_here"
//! ```
//!
//! Finally, (compile and) run the example:
//!
//! ```bash
//! cargo run
//! ```

pub mod enhancement {
    //! Load a model, configure a processor and enhance a block of audio.
    //!
    //! Follow the instructions at [`examples`](super), using the following code in `src/main.rs`:
    //!
    //! ```no_run
    //! # #[cfg(feature = "download-model")]
    //! # fn example() {
    #![doc = include_str!("../../examples/enhancement.rs")]
    //! # }
    //! ```
}

pub mod vad {
    //! Detect speech with a dedicated VAD model and read the prediction from a VAD context.
    //!
    //! Follow the instructions at [`examples`](super), using the following code in `src/main.rs`:
    //!
    //! ```no_run
    //! # #[cfg(feature = "download-model")]
    //! # fn example() {
    #![doc = include_str!("../../examples/vad.rs")]
    //! # }
    //! ```
}

pub mod analyze_file {
    //! Analyze a WAV file given on the command line and print the resulting scores.
    //!
    //! In addition to the instructions at [`examples`](super), you have to add the `audio-file` crate
    //! (if you want to use formats other than WAV, drop `--no-default-features`):
    //!
    //! ```bash
    //! cargo add audio-file --no-default-features
    //! ```
    //!
    //! When running the example, specify the path to an audio file to be analyzed:
    //!
    //! ```bash
    //! cargo run -- path/to/audio-file.wav
    //! ```
    //!
    //! `src/main.rs`:
    //! ```no_run
    //! # #[cfg(feature = "download-model")]
    //! # fn example() {
    #![doc = include_str!("../../examples/analyze_file.rs")]
    //! # }
    //! ```
}

pub mod benchmark {
    //! Run processor instances concurrently until they stop keeping up with real time, to find how
    //! many streams a machine sustains.
    //!
    //! In addition to the instructions at [`examples`](super), you have to add the `tokio` crate,
    //! enabling a few features:
    //!
    //! ```bash
    //! cargo add tokio --features macros,rt-multi-thread,sync,time
    //! ```
    //!
    //! `src/main.rs`:
    //! ```no_run
    //! # #[cfg(feature = "download-model")]
    //! # fn example() {
    #![doc = include_str!("../../examples/benchmark.rs")]
    //! # }
    //! ```
}

#[cfg(feature = "async")]
pub mod parallel_async {
    //! Process several streams concurrently with [`ProcessorAsync`] on an async runtime.
    //!
    //! In addition to the instructions at [`examples`](super),
    //! you have to enable the `async` feature:
    //!
    //! ```bash
    //! cargo add aic-sdk --features download-lib,download-model,async
    //! ```
    //!
    //! And you have to add two more crates:
    //!
    //! ```bash
    //! cargo add futures
    //! cargo add tokio --features macros,rt-multi-thread
    //! ```
    //!
    //! `src/main.rs`:
    //! ```no_run
    //! # #[cfg(all(feature = "async", feature = "download-model"))]
    //! # fn example() {
    #![doc = include_str!("../../examples/parallel_async.rs")]
    //! # }
    //! ```
    #[allow(unused_imports)]
    // Used in the docstring:
    use crate::ProcessorAsync;
}

pub mod build_time_download {
    //! Download a model while the program is compiled and embed it into the binary.
    #![doc = include_str!("../../examples/build-time-download/README.md")]
    //!
    //! `build.rs`:
    //!
    //! ```no_run
    //! # #[cfg(feature = "download-model")]
    //! # fn build_script() {
    #![doc = include_str!("../../examples/build-time-download/build.rs")]
    //! # }
    //! ```
    //!
    //! `src/main.rs`:
    //!
    //! ```no_run
    //! # macro_rules! include_model { ($($tt:tt)*) => { &[] } }
    #![doc = include_str!("../../examples/build-time-download/src/main.rs")]
    //! ```
    #[allow(unused_imports)]
    // These are linked in the README.md:
    use crate::{Model, include_model};
}