Vosk Speech Recognition Toolkit

repository·master·Indexed 12 days ago

https://github.com/alphacep/vosk-api

An offline, open-source speech recognition toolkit providing low-latency, large-vocabulary transcription for over 20 languages. Designed to scale from embedded devices like Raspberry Pi and Android smartphones to large server clusters, it features a streaming API for zero-latency response and small model footprints (approx. 50 MB). Supports multiple language bindings including C#, Go, Java, Kotlin, Node.js, and Ruby.

Tokens
18.5K
Snippets
81
Records
101
Agent score
96%

What's inside Vosk

  1. Overview of the Vosk Speech Recognition Toolkit

    master

    Vosk is an offline, open-source speech recognition toolkit designed for high-performance transcription. It supports over 20 languages and dialects, including English, German, French, Spanish, Chinese, Russian, and more.

    Key features include:

    • Small Model Size: Models are approximately 50 MB.
    • Continuous Transcription: Supports large vocabulary transcription.
    • Low Latency: Provides zero-latency responses via a streaming API.
    • Advanced Capabilities: Supports reconfigurable vocabulary and speaker identification.
    • Scalability: Runs on devices ranging from Raspberry Pi and Android smartphones to large computing clusters.
    • Multi-language Support: Covers English, Indian English, German, French, Spanish, Portuguese, Chinese, Russian, Turkish, Vietnamese, Italian, Dutch, Catalan, Arabic, Greek, Farsi, Filipino, Ukrainian, Kazakh, Swedish, Japanese, Esperanto, Hindi, Czech, and Polish.
  2. Overview of Vosk Speech Recognition capabilities

    master

    Vosk is an offline, open-source speech recognition toolkit designed to scale from small devices (like Raspberry Pi or Android smartphones) to large clusters.

    Key features include:

    • Multi-language support: Supports 20+ languages and dialects (including English, German, French, Spanish, Chinese, Russian, and more).
    • Small Model Footprint: Models are approximately 50 MB.
    • Streaming API: Provides zero-latency response for continuous large vocabulary transcription.
    • Advanced Features: Supports reconfigurable vocabulary and speaker identification.
    • Use Cases: Ideal for chatbots, smart home appliances, virtual assistants, subtitle generation, and lecture/interview transcription.
  3. Overview of Vosk Speech Recognition Toolkit

    master

    Vosk is an offline, open-source speech recognition toolkit designed for high-performance transcription. It supports over 20 languages and dialects (including English, German, French, Spanish, Chinese, Russian, and more) and is optimized for a wide range of hardware, from small devices like Raspberry Pi and Android smartphones to large server clusters.

    Key features include:

    • Continuous large vocabulary transcription.
    • Zero-latency response via a streaming API.
    • Small model sizes (starting around 50 MB).
    • Reconfigurable vocabulary and speaker identification.

    Common use cases include chatbots, smart home appliances, virtual assistants, subtitle generation, and lecture/interview transcription.

  4. Supported platforms for Vosk C#

    master

    The Vosk C# wrapper currently only supports the following architectures:

    • win64 (Windows 64-bit)
    • linux64 (Linux 64-bit)

    Note that win32 is not supported due to library loading complexities. Support for OSX or Android is not currently implemented.

  5. Build the vosk-api-kotlin project

    master

    To build the project from source using Gradle, ensure you have the following prerequisites met:

    1. Install libvosk: Either build from source or download the binaries.
    2. Download a Vosk model: Obtain a model from the official Vosk models page.
    3. Configure Environment Variables: Set the following variables so the build/tests can locate the necessary files:
      • VOSK_MODEL: The path to your downloaded Vosk model.
      • VOSK_PATH: The path to your libvosk installation.

    Once configured, run the build command:

    ./gradlew build
  6. Set up Vosk Java bindings

    master

    To use the Vosk API in Java, you must use the provided Java bindings which rely on jnr-ffi.

    1. Build the project: Use Gradle to build the demo project.
    2. Configure the model: Download a Vosk speech model and unpack it into a folder named model within the root directory of the demo project.
    3. Requirements: Ensure you are using a recent version of the JDK and Gradle.
    # Example build command (assuming Gradle is installed)
    ./gradlew build
  7. Enable Kotlin/Native development

    master

    The Kotlin/Native target is disabled by default. To enable it for development, you must first ensure libvosk is installed in the proper UNIX directories as defined in src/nativeInterop/cinterop/libvosk.def.

    To activate the native target, use one of the following methods:

    • Set the environment variable NATIVE_EXPERIMENT=true.
    • Modify build.gradle.kts by setting enableNative = true.

    After syncing the project, run the following task to generate the Kotlin C bindings: cinteropLibvoskNative

    # Method 1: Environment variable
    export NATIVE_EXPERIMENT=true
    
    # Method 2: Edit build.gradle.kts
    # enableNative = true
  8. Run the Vosk C# demo

    master

    To see a working example of the Vosk C# wrapper, navigate to the demo folder and execute the following command. Ensure you have already unpacked your Vosk model and the test audio file into the expected locations before running.

    dotnet run
  9. Run the Go batch processing example

    master

    The Go batch processing example converts s16le converted audio files to text. It is designed to imitate the behavior of the Python test_gpu_batch.py example for batch processing.

    Prerequisites:

    • An audio file converted to s16le format.
    • The libvosk.so library must be present in your system's library path (e.g., LD_LIBRARY_PATH).

    Tested Environment:

    • Ubuntu 24.04
    • Go 1.18
    • gcc-11
    • NVIDIA driver 570.172.08
  10. Run the Vosk Go example on Windows

    master

    To run the Vosk Go example on Windows, download the library binaries and place the .dll and .h files directly into the current working directory so the linker can find them. You must also download a speech model and place it in a directory named model. Use the -f flag to specify the input .wav file.

    git clone https://github.com/alphacep/vosk-api
    cd vosk-api/go/example
    wget https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-linux-x86_64-0.3.45.zip
    unzip vosk-linux-x86_64-0.3.45.zip
    cp vosk-linux-x86_64-0.3.45/*.dll .
    cp vosk-linux-x86_64-0.3.45/*.h .
    wget https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip
    unzip vosk-model-small-en-us-0.15.zip
    mv vosk-model-small-en-us-0.15 model
    cp ../../python/example/test.wav .
    VOSK_PATH=`pwd` LD_LIBRARY_PATH=$VOSK_PATH CGO_CPPFLAGS="-I $VOSK_PATH" CGO_LDFLAGS="-L $VOSK_PATH -lvosk -lpthread -dl" go run . -f test.wav
  11. Use the Vosk FFI-NAPI wrapper for Node.js

    master

    The vosk-js package is an FFI-NAPI wrapper for the Vosk library, allowing you to use Vosk's offline speech recognition capabilities in Node.js environments. The bindings largely follow the standard Vosk interface, though some methods may not be fully implemented in this wrapper.

    For implementation details and specific usage patterns, refer to the demo folder in the repository.

  12. Access Vosk installation instructions and documentation

    master

    For detailed installation instructions, code examples, and comprehensive documentation for all language bindings, visit the official Vosk website.

    https://alphacephei.com/vosk