| Crates.io | aprilasr-sys |
| lib.rs | aprilasr-sys |
| version | 0.1.3 |
| created_at | 2024-01-27 16:48:53.323097+00 |
| updated_at | 2024-02-04 22:39:25.195558+00 |
| description | Low-level FFI bindings for the april-asr C api (libaprilasr). |
| homepage | |
| repository | https://codeberg.org/vhs/aprilasr-sys |
| max_upload_size | |
| id | 1116826 |
| size | 338,568 |
Low-level FFI bindings for the april-asr C api (libaprilasr).
Compiles libaprilasr from source to OUT_DIR using CMake and generates bindings for April API, made available via vendored upstream source pointing at a specific commit sha as defined by the git submodule.
Building requires the following system libraries:
Use locate to search for installed libraries. For example, on Linux run command locate libonnxruntime.so to determine if the ONNX Runtime is available.
To get the latest unyanked release published to crates.io:
cargo add aprilasr-sys
Or get the tip of the development branch via cargo using git:
cargo add --git https://codeberg.org/vhs/aprilasr-sys.git
It's also possible to vendor this crate:
mkdir crates && \
(cd crates; git submodule add https://codeberg.org/vhs/aprilasr-sys)
And once cloned updating dependent's Cargo.toml manifest like:
[dependencies]
aprilasr-sys = { path = "crates/aprilasr-sys" }
For a basic usage example see examples/init.rs and run command:
cargo run --example init
You should see output like:
April ASR api v1 initialized and ready for model.
First clone vendored source:
git submodule update --init --recursive
To generate bindings run command:
cargo build [--release]
To specify include directory set env APRIL_INCLUDE_DIR before running build.
To inspect bindings generated:
bat $(echo $(exa target/*/build/*/out/bindings.rs) | head -1)
Command requires bat and exa rust binaries and displays output with syntax highlighting.
Consider using chrono to parse the date format unless april-asr adopts semantic versioning:
let date_str = "2023.05.12";
let native_date = chrono::NaiveDate::parse_from_str(date_str, "%Y.%m.%d");
p!("{:?}", native_date);
Here p! is a debug helper in build.rs and date_str represents the VERSION in vendor/april-asr/CMakeLists.txt file. With some additional work cmake-parser looks well-suited for parsing the file to get the version.
Date-based versioning is not currently implemented in the build.rs build script. Once versioning is implemented it would also ideal to use it as an input to pkg-config to scan the system for the library.
See Making a *-sys crate for other possible enhancements.
Because we are vendoring April ASR source using a git submodule we have the ability to update the submodule to generate new bindings when the upstream source code changes.
To view the current commit of the april-asr submodule:
git submodule status | awk '{print substr($1, 1, 7)}'
To update the submodule to the latest commit in the main branch of the submodule:
git submodule update --remote --recursive --merge
This command fetches the latest commits from the submodule's remote repository, checks out the commit referenced by the main branch, and updates the submodule in the main repository.
Steps to package a release of this crate for crates.io:
cargo clean to remove existing build artifacts.cargo build --release to update generated bindings.cargo test to execute unit tests including bindgen.cargo run --example init to check example.cargo doc to generate crate docs and review them.Cargo.toml manifest.cargo publish --dry-run to review your work.cargo login and cargo publish to publish crate.Once published visit docs.rs to review crate documentation.