百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
V

vosk-rs

> 编程语言
开源

Rust 绑定到 Vosk API 语音识别库

180 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Rust 绑定到 Vosk API 语音识别库

Vosk

Safe FFI bindings around the Vosk API Speech Recognition Toolkit.

Usage

…

Setup

Compilation

The Vosk-API libraries have to be discoverable by the rust linker. Download the zip file containing the dynamic libraries for your platform here. For iOS development you have to use static libraries. Get the static libraries from the vosk-api team.

Using dynamic libraries

Do either of the following:

  • Recommended: Create a build script and provide cargo with the path to the libraries
  • Use the RUSTFLAGS environment variable to provide the path to the variables like so: RUSTFLAGS=-L/path/to/the/libraries with cargo:rustc-link-search or cargo:rustc-link-lib.
  • Make the vosk library accessible system or user-wide:
    • Windows: Move the libraries to a directory in your PATH environment variable.
    • Linux: Move them to /usr/local/lib, /usr/lib or set the LIBRARY_PATH environment variable to the directory containing the libraries.

Although the approaches are equivalent, using a build script is more convenient because it does not require the developer to remember a terminal command or change anything outside the project scope.

Using static libraries (macOS-only, targeting iOS)

  • Extract the correct non-fat file (also called thin file) from the static fat file (libvosk.a) for each architecture you would like to support.
  • Mark your crate type as staticlib.
  • Create a build script and provide cargo with the path to the libraries with cargo:rustc-link-search= and cargo:rustc-link-lib=static=.
Troubleshooting

In real-world scenarios, one will use Rust to cross compile a library (e.g. Android and iOS). Therefore, we need both cdylib as well as the staticlib as crate-type. If you compile as usual with cargo build (e.g.: cargo build --target aarch64-apple-ios --release) it will not work, because cargo tries to build the dylib as well. Fortunately, since rust 1.64, there is a new option for rustc in the stable channel. Because of this, the following will work: cargo rustc --crate-type staticlib --lib --target aarch64-apple-ios --release

Execution

Executables compiled with a dynamic lib must have access to the vosk library at runtime. Executables compiled with a statically compiled library do not.

Using dynamic libraries

Do either of the following:

  • Recommended: Copy the libraries to the root of the executable (target/ by default). It is recommended that you use a tool such as cargo-make to automate moving the libraries from another, more practical, directory to the destination during build.
  • Make the vosk library accessible system or user-wide:
    • Windows: Move the libraries to a directory in your PATH environment variable.
    • Linux: Move them to /usr/local/lib, /usr/lib or set the LD_LIBRARY_PATH environment variable to the directory containing the libraries. Note: LD_LIBRARY_PATH is not the same as LIBRARY_PATH mentioned in the compilation step.

Using static libraries (iOS-only)

  • Add the compiled .a library (or libraries if you would like to support more than one architecture) to your iOS project
  • Set Enable Bitcode to no for your target
  • Add the Accelerate Framework from the iOS SDK to your project
  • Depending on your library and use case, you have to write some C -> Objective-C -> Swift glue code.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言