/vosk.zig

Vosk, built with Zig

Primary LanguageZigApache License 2.0Apache-2.0

vosk.zig

Build vosk-api using zig.

Status

  • MacOS (using linkFramework("Accelerate"))
  • Linux (using linkSystemLibrary("openblas"))

Build

zig build -Doptimize=ReleaseFast -Dtarget=x86_64-native -p vosk/x86_64-macos
zig build -Doptimize=ReleaseFast -Dtarget=aarch64-native -p vosk/aarch64-macos

Result (on MacOS):

% tree vosk
vosk
├── aarch64-macos
│   ├── include
│   │   └── vosk_api.h
│   └── lib
│       └── libvosk.dylib
└── x86_64-macos
    ├── include
    │   └── vosk_api.h
    └── lib
        └── libvosk.dylib

Examples

zig build -Doptimize=ReleaseFast example-static
zig build -Doptimize=ReleaseFast example-shared
zig build -Doptimize=ReleaseFast example-zig

Usage

C/C++

zig cc -Ivosk/aarch64-macos/include -Lvosk/aarch64-macos/lib src/example.c -lvosk -Wl,-rpath,vosk/aarch64-macos/lib
./a.out path/to/model path/to/wav

FFI

git clone -b ruby https://github.com/jethrodaniel/vosk-api
cd vosk-api/ruby

cp -v path/to/libvosk.dylib .

bundle
bundle exec ruby examples/transcribe.rb

Zig

See the example-zig step in build.zig.

License

Apache-2.0, same as vosk-api.