Full Code of alphacep/vosk-api for AI

master 9adbd76c7733 cached
255 files
3.9 MB
1.0M tokens
578 symbols
1 requests
Download .txt
Showing preview only (4,157K chars total). Download the full file or copy to clipboard to get everything.
Repository: alphacep/vosk-api
Branch: master
Commit: 9adbd76c7733
Files: 255
Total size: 3.9 MB

Directory structure:
gitextract_hf0bzx57/

├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── COPYING
├── README.md
├── android/
│   ├── README.md
│   ├── build.gradle
│   ├── lib/
│   │   ├── build-vosk.sh
│   │   ├── build.gradle
│   │   └── src/
│   │       └── main/
│   │           ├── AndroidManifest.xml
│   │           ├── java/
│   │           │   └── org/
│   │           │       └── vosk/
│   │           │           ├── LibVosk.java
│   │           │           ├── LogLevel.java
│   │           │           ├── Model.java
│   │           │           ├── Recognizer.java
│   │           │           ├── SpeakerModel.java
│   │           │           ├── TextProcessor.java
│   │           │           └── android/
│   │           │               ├── RecognitionListener.java
│   │           │               ├── SpeechService.java
│   │           │               ├── SpeechStreamService.java
│   │           │               └── StorageService.java
│   │           └── jniLibs/
│   │               ├── arm64-v8a/
│   │               │   └── .keep-me
│   │               ├── armeabi-v7a/
│   │               │   └── .keep-me
│   │               ├── x86/
│   │               │   └── .keep-me
│   │               └── x86_64/
│   │                   └── .keep-me
│   ├── model-en/
│   │   ├── build.gradle
│   │   └── src/
│   │       └── main/
│   │           └── AndroidManifest.xml
│   └── settings.gradle
├── c/
│   ├── Makefile
│   ├── test_vosk.c
│   └── test_vosk_speaker.c
├── csharp/
│   ├── README.md
│   ├── demo/
│   │   ├── VoskDemo.cs
│   │   └── VoskDemo.csproj
│   └── nuget/
│       ├── Vosk.csproj
│       ├── Vosk.nuspec
│       ├── build/
│       │   ├── Vosk.targets
│       │   └── lib/
│       │       ├── linux-x64/
│       │       │   └── .keep-me
│       │       ├── osx-universal/
│       │       │   └── .keep-me
│       │       └── win-x64/
│       │           └── .keep-me
│       ├── build.sh
│       └── src/
│           ├── BatchModel.cs
│           ├── Model.cs
│           ├── SpkModel.cs
│           ├── Vosk.cs
│           ├── VoskBatchRecognizer.cs
│           ├── VoskPINVOKE.cs
│           └── VoskRecognizer.cs
├── go/
│   ├── COPYING
│   ├── README.md
│   ├── batch.go
│   ├── batch_example/
│   │   ├── README.md
│   │   └── test_batch.go
│   ├── doc.go
│   ├── example/
│   │   ├── README.md
│   │   ├── doc.go
│   │   └── test_simple.go
│   ├── go.mod
│   └── vosk.go
├── ios/
│   ├── README
│   ├── VoskApiTest/
│   │   ├── AppDelegate.swift
│   │   ├── Assets.xcassets/
│   │   │   └── AppIcon.appiconset/
│   │   │       └── Contents.json
│   │   ├── Base.lproj/
│   │   │   ├── LaunchScreen.storyboard
│   │   │   └── Main.storyboard
│   │   ├── Info.plist
│   │   ├── ViewController.swift
│   │   ├── Vosk/
│   │   │   └── vosk_api.h
│   │   ├── Vosk.swift
│   │   ├── VoskModel.swift
│   │   └── bridging.h
│   └── VoskApiTest.xcodeproj/
│       ├── project.pbxproj
│       └── project.xcworkspace/
│           └── contents.xcworkspacedata
├── java/
│   ├── README.md
│   ├── demo/
│   │   ├── build.gradle
│   │   └── src/
│   │       └── main/
│   │           └── java/
│   │               └── org/
│   │                   └── vosk/
│   │                       └── demo/
│   │                           └── DecoderDemo.java
│   └── lib/
│       ├── build.gradle
│       └── src/
│           ├── main/
│           │   ├── java/
│           │   │   └── org/
│           │   │       └── vosk/
│           │   │           ├── LibVosk.java
│           │   │           ├── LogLevel.java
│           │   │           ├── Model.java
│           │   │           ├── Recognizer.java
│           │   │           └── SpeakerModel.java
│           │   └── resources/
│           │       ├── darwin/
│           │       │   └── .keep-me
│           │       ├── linux-x86-64/
│           │       │   └── .keep-me
│           │       └── win32-x86-64/
│           │           ├── .keep-me
│           │           └── empty
│           └── test/
│               └── java/
│                   └── org/
│                       └── vosk/
│                           └── test/
│                               └── DecoderTest.java
├── kotlin/
│   ├── .gitignore
│   ├── AUTHORS
│   ├── MAINTENANCE.md
│   ├── README.md
│   ├── build.gradle.kts
│   ├── settings.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   ├── AndroidManifest.xml
│       │   └── kotlin/
│       │       └── org/
│       │           └── vosk/
│       │               └── android/
│       │                   ├── RecognitionListener.kt
│       │                   ├── SpeechService.kt
│       │                   ├── SpeechStreamService.kt
│       │                   └── StorageService.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── org/
│       │           └── vosk/
│       │               ├── AcceptWaveformException.kt
│       │               ├── BatchModel.kt
│       │               ├── BatchRecognizer.kt
│       │               ├── EndPointerMode.kt
│       │               ├── Freeable.kt
│       │               ├── LogLevel.kt
│       │               ├── Model.kt
│       │               ├── Recognizer.kt
│       │               ├── SpeakerModel.kt
│       │               ├── TextProcessor.kt
│       │               ├── Vosk.kt
│       │               ├── exception/
│       │               │   ├── IOException.kt
│       │               │   ├── ModelException.kt
│       │               │   └── RecognizerException.kt
│       │               └── json/
│       │                   ├── Alternative.kt
│       │                   ├── Extension.kt
│       │                   ├── PartialResultOutput.kt
│       │                   ├── Result.kt
│       │                   ├── ResultOutput.kt
│       │                   └── WaveformResult.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── org/
│       │           └── vosk/
│       │               ├── BatchModel.kt
│       │               ├── BatchRecognizer.kt
│       │               ├── LibVosk.kt
│       │               ├── Model.kt
│       │               ├── Recognizer.kt
│       │               ├── SpeakerModel.kt
│       │               ├── TextProcessor.kt
│       │               ├── Vosk.kt
│       │               ├── WaveformExt.kt
│       │               └── exception/
│       │                   └── IOException.kt
│       ├── jvmTest/
│       │   └── kotlin/
│       │       └── DecoderTest.kt
│       ├── nativeInterop/
│       │   └── cinterop/
│       │       └── libvosk.def
│       └── nativeMain/
│           └── kotlin/
│               └── org/
│                   └── vosk/
│                       ├── BatchModel.kt
│                       ├── BatchRecognizer.kt
│                       ├── FreeableExt.kt
│                       ├── IOException.kt
│                       ├── Model.kt
│                       ├── Recognizer.kt
│                       ├── SpeakerModel.kt
│                       ├── Utils.kt
│                       └── Vosk.kt
├── nodejs/
│   ├── .npmignore
│   ├── README.md
│   ├── demo/
│   │   ├── test_ffmpeg.js
│   │   ├── test_microphone.js
│   │   ├── test_simple.js
│   │   ├── test_simple_async.js
│   │   ├── test_speaker.js
│   │   └── test_srt.js
│   ├── index.js
│   └── package.json
├── python/
│   ├── .pylintrc
│   ├── README.md
│   ├── example/
│   │   ├── colab/
│   │   │   ├── kaldi-build.ipynb
│   │   │   ├── vosk-adaptation.ipynb
│   │   │   ├── vosk-training.ipynb
│   │   │   └── vosk.ipynb
│   │   ├── test_alternatives.py
│   │   ├── test_empty.py
│   │   ├── test_ep.py
│   │   ├── test_ffmpeg.py
│   │   ├── test_gpu_batch.py
│   │   ├── test_gradio.py
│   │   ├── test_itn.py
│   │   ├── test_microphone.py
│   │   ├── test_nlsml.py
│   │   ├── test_reset.py
│   │   ├── test_simple.py
│   │   ├── test_speaker.py
│   │   ├── test_srt.py
│   │   ├── test_text.py
│   │   ├── test_webvtt.py
│   │   └── test_words.py
│   ├── setup.py
│   ├── test/
│   │   └── transcribe_scp.py
│   ├── vosk/
│   │   ├── __init__.py
│   │   └── transcriber/
│   │       ├── __init__.py
│   │       ├── cli.py
│   │       └── transcriber.py
│   └── vosk_builder.py
├── ruby/
│   ├── .gitignore
│   ├── .rspec
│   ├── .rubocop.yml
│   ├── Gemfile
│   ├── README.md
│   ├── Rakefile
│   ├── bin/
│   │   ├── console
│   │   └── setup
│   ├── example/
│   │   ├── test_simple.rb
│   │   ├── test_srt.rb
│   │   └── test_words.rb
│   ├── exe/
│   │   └── vosk-transcriber
│   ├── lib/
│   │   ├── vosk/
│   │   │   ├── ffi.rb
│   │   │   ├── progressbar.rb
│   │   │   └── version.rb
│   │   └── vosk.rb
│   ├── sig/
│   │   └── vosk.rbs
│   ├── spec/
│   │   ├── spec_helper.rb
│   │   ├── vosk/
│   │   │   └── model_spec.rb
│   │   └── vosk_spec.rb
│   └── vosk.gemspec
├── rust/
│   └── README.md
├── src/
│   ├── Makefile
│   ├── batch_model.cc
│   ├── batch_model.h
│   ├── batch_recognizer.cc
│   ├── batch_recognizer.h
│   ├── json.h
│   ├── language_model.cc
│   ├── language_model.h
│   ├── model.cc
│   ├── model.h
│   ├── postprocessor.cc
│   ├── postprocessor.h
│   ├── recognizer.cc
│   ├── recognizer.h
│   ├── spk_model.cc
│   ├── spk_model.h
│   ├── vosk_api.cc
│   └── vosk_api.h
├── training/
│   ├── README.md
│   ├── RESULTS
│   ├── RESULTS.txt
│   ├── cmd.sh
│   ├── conf/
│   │   ├── mfcc.conf
│   │   └── online_cmvn.conf
│   ├── local/
│   │   ├── chain/
│   │   │   ├── run_ivector_common.sh
│   │   │   └── run_tdnn.sh
│   │   ├── data_prep.sh
│   │   ├── download_and_untar.sh
│   │   ├── download_lm.sh
│   │   ├── prepare_dict.sh
│   │   └── score.sh
│   ├── path.sh
│   └── run.sh
├── travis/
│   ├── Dockerfile.dockcross
│   ├── Dockerfile.dockcross-manylinux
│   ├── Dockerfile.dockcross-musl
│   ├── Dockerfile.manylinux
│   ├── Dockerfile.manylinux-mkl
│   ├── Dockerfile.win
│   ├── Dockerfile.win32
│   ├── Dockerfile.winaarch64
│   ├── build-dockcross-manylinux.sh
│   ├── build-dockcross-musl.sh
│   ├── build-dockcross.sh
│   ├── build-docker-mkl.sh
│   ├── build-docker-win.sh
│   ├── build-docker-win32.sh
│   ├── build-docker-winaarch64.sh
│   ├── build-docker.sh
│   ├── build-wheels-dockcross.sh
│   ├── build-wheels-mkl.sh
│   ├── build-wheels-win.sh
│   ├── build-wheels-win32.sh
│   ├── build-wheels-winaarch64.sh
│   └── build-wheels.sh
└── webjs/
    ├── index.js
    └── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Object files
*.o

# Temp files
nohup.out

# Gradle files
.gradle/
gradlew
gradlew.bat
gradle
local.properties
gradle.properties

# Android
android/build
android/lib/build
android/model-en/build
android/model-en/src/main/assets/model-en-us
android/repo
*.apk
*.ap_

# Cmake
.cxx
cmake_install.cmake

# Python
wheelhouse
__pycache__
*.egg-info
python/dist
python/build
python/vosk/*.so
python/test/db
python/test/hyp
python/test/model
python/test/ref
python/test/result.txt
python/test/wav.scp

# Java
*.class
java/lib/model
java/demo/model
java/lib/build
java/demo/build

# CSharp
*.dll
*.so
*.dylib
*.nupkg
csharp/demo/model
csharp/demo/test.wav
csharp/demo/bin
csharp/demo/obj

# Node
nodejs/demo/model
nodejs/demo/model-spk
nodejs/demo/test.wav
nodejs/node_modules
nodejs/package-lock.json

# C
c/test_vosk
c/test_vosk_speaker
c/oprofile_data
c/model
c/test.wav


================================================
FILE: .travis.yml
================================================
notifications:
  email: false

matrix:
  include:
    - sudo: required
      services:
        - docker
      env: DOCKER_IMAGE=alphacep/kaldi-manylinux:latest

install:
  - docker pull $DOCKER_IMAGE

script:
  - docker run --rm -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/travis/build-wheels.sh
  - ls wheelhouse/


================================================
FILE: CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.13)
project(vosk-api CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)

add_library(vosk
  src/language_model.cc
  src/model.cc
  src/recognizer.cc
  src/spk_model.cc
  src/vosk_api.cc
  src/postprocessor.cc
)

find_package(kaldi REQUIRED)
target_link_libraries(vosk PUBLIC kaldi-base kaldi-online2 kaldi-rnnlm fstngram)

include(GNUInstallDirs)
install(TARGETS vosk DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES src/vosk_api.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})


================================================
FILE: COPYING
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. this License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS


================================================
FILE: README.md
================================================
# Vosk Speech Recognition Toolkit

Vosk is an offline open source speech recognition toolkit. It enables
speech recognition for 20+ languages and dialects - 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, Polish.
More to come.

Vosk models are small (50 Mb) but provide continuous large vocabulary
transcription, zero-latency response with streaming API, reconfigurable
vocabulary and speaker identification.

Speech recognition bindings implemented for various programming languages
like Python, Java, Node.JS, C#, C++, Rust, Go and others.

Vosk supplies speech recognition for chatbots, smart home appliances,
virtual assistants. It can also create subtitles for movies,
transcription for lectures and interviews.

Vosk scales from small devices like Raspberry Pi or Android smartphone to
big clusters.

# Documentation

For installation instructions, examples and documentation visit [Vosk
Website](https://alphacephei.com/vosk).


================================================
FILE: android/README.md
================================================
Vosk library for Android

See for details https://alphacephei.com/vosk/android


================================================
FILE: android/build.gradle
================================================
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.13.0'
        classpath 'com.vanniktech:gradle-maven-publish-plugin:0.34.0'
    }
}

allprojects {
    version = '0.3.75'
}

subprojects {

    apply plugin: 'com.android.library'
    apply plugin: 'com.vanniktech.maven.publish'

    repositories {
        google()
        mavenCentral()
    }

    mavenPublishing {
        publishToMavenCentral()
        signAllPublications()
    }

    mavenPublishing {
        pom {
            url = 'http://www.alphacephei.com.com/vosk/'
            licenses {
                license {
                    name = 'The Apache License, Version 2.0'
                    url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                }
            }
            developers {
                developer {
                    id = 'com.alphacephei'
                    name = 'Alpha Cephei Inc'
                    email = 'contact@alphacephei.com'
                }
            }
            scm {
                connection = 'scm:git:git://github.com/alphacep/vosk-api.git'
                url = 'https://github.com/alphacep/vosk-api/'
            }
        }
    }
}


================================================
FILE: android/lib/build-vosk.sh
================================================
#!/bin/bash

# Copyright 2019-2021 Alpha Cephei Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if [ "x$ANDROID_NDK_HOME" == "x" ]; then
    echo "ANDROID_NDK_HOME environment variable is undefined, define it with local.properties or with export"
    exit 1
fi

if [ ! -d "$ANDROID_NDK_HOME" ]; then
    echo "ANDROID_NDK_HOME ($ANDROID_NDK_HOME) is missing. Make sure you have ndk installed"
    exit 1
fi

set -x

OS_NAME=`echo $(uname -s) | tr '[:upper:]' '[:lower:]'`
ANDROID_TOOLCHAIN_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/${OS_NAME}-x86_64
WORKDIR_BASE=`pwd`/build
PATH=$ANDROID_TOOLCHAIN_PATH/bin:$PATH
OPENFST_VERSION=1.8.0

for arch in armeabi-v7a arm64-v8a x86_64 x86; do

WORKDIR=${WORKDIR_BASE}/kaldi_${arch}

case $arch in
    armeabi-v7a)
          BLAS_ARCH=ARMV7
          HOST=arm-linux-androideabi
          AR=llvm-ar
          RANLIB=llvm-ranlib
          CC=armv7a-linux-androideabi21-clang
          CXX=armv7a-linux-androideabi21-clang++
          ARCHFLAGS="-mfloat-abi=softfp -mfpu=neon"
          PAGESIZE_LDFLAGS=""
          ;;
    arm64-v8a)
          BLAS_ARCH=ARMV8
          HOST=aarch64-linux-android
          AR=llvm-ar
          RANLIB=llvm-ranlib
          CC=aarch64-linux-android21-clang
          CXX=aarch64-linux-android21-clang++
          ARCHFLAGS=""
          # Ensure compatibility with 16KiB page size devices
          PAGESIZE_LDFLAGS="-Wl,-z,common-page-size=4096 -Wl,-z,max-page-size=16384"
          ;;
    x86_64)
          BLAS_ARCH=ATOM
          HOST=x86_64-linux-android
          AR=llvm-ar
          RANLIB=llvm-ranlib
          CC=x86_64-linux-android21-clang
          CXX=x86_64-linux-android21-clang++
          ARCHFLAGS=""
          PAGESIZE_LDFLAGS=""
          ;;
    x86)
          BLAS_ARCH=ATOM
          HOST=i686-linux-android
          AR=llvm-ar
          RANLIB=llvm-ranlib
          CC=i686-linux-android21-clang
          CXX=i686-linux-android21-clang++
          ARCHFLAGS=""
          PAGESIZE_LDFLAGS=""
          ;;
esac

mkdir -p $WORKDIR/local/lib

# openblas first
cd $WORKDIR
git clone -b v0.3.20 --single-branch https://github.com/xianyi/OpenBLAS
make -C OpenBLAS TARGET=$BLAS_ARCH ONLY_CBLAS=1 AR=$AR CC=$CC HOSTCC=gcc ARM_SOFTFP_ABI=1 USE_THREAD=0 NUM_THREADS=1 -j 8
make -C OpenBLAS install PREFIX=$WORKDIR/local

# CLAPACK
cd $WORKDIR
git clone -b v3.2.1  --single-branch https://github.com/alphacep/clapack
mkdir -p clapack/BUILD && cd clapack/BUILD
cmake -DCMAKE_C_FLAGS="$ARCHFLAGS" -DCMAKE_C_COMPILER_TARGET=$HOST \
    -DCMAKE_C_COMPILER=$CC -DCMAKE_SYSTEM_NAME=Generic -DCMAKE_AR=$ANDROID_TOOLCHAIN_PATH/bin/$AR \
    -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
    -DCMAKE_CROSSCOMPILING=True ..
make -j 8 -C F2CLIBS/libf2c
make -j 8 -C BLAS/SRC
make -j 8 -C SRC
find . -name "*.a" | xargs cp -t $WORKDIR/local/lib

# tools directory --> we'll only compile OpenFST
cd $WORKDIR
git clone https://github.com/alphacep/openfst
cd openfst
autoreconf -i
CXX=$CXX CXXFLAGS="$ARCHFLAGS -O3 -DFST_NO_DYNAMIC_LINKING" ./configure --prefix=${WORKDIR}/local \
    --enable-shared --enable-static --with-pic --disable-bin \
    --enable-lookahead-fsts --enable-ngram-fsts --host=$HOST --build=x86-linux-gnu
make -j 8
make install

# Kaldi itself
cd $WORKDIR
git clone -b vosk-android --single-branch https://github.com/alphacep/kaldi
cd $WORKDIR/kaldi/src
CXX=$CXX AR=$AR RANLIB=$RANLIB CXXFLAGS="$ARCHFLAGS -O3 -DFST_NO_DYNAMIC_LINKING" ./configure --use-cuda=no \
    --mathlib=OPENBLAS_CLAPACK --shared \
    --android-incdir=${ANDROID_TOOLCHAIN_PATH}/sysroot/usr/include \
    --host=$HOST --openblas-root=${WORKDIR}/local \
    --fst-root=${WORKDIR}/local --fst-version=${OPENFST_VERSION}
make -j 8 depend
cd $WORKDIR/kaldi/src
make -j 8 online2 rnnlm

# Vosk-api
cd $WORKDIR
mkdir -p $WORKDIR/vosk
make -j 8 -C ${WORKDIR_BASE}/../../../src \
    OUTDIR=$WORKDIR/vosk \
    KALDI_ROOT=${WORKDIR}/kaldi \
    OPENFST_ROOT=${WORKDIR}/local \
    OPENBLAS_ROOT=${WORKDIR}/local \
    CXX=$CXX \
    EXTRA_LDFLAGS="-llog -static-libstdc++ -Wl,-soname,libvosk.so ${PAGESIZE_LDFLAGS}"
cp $WORKDIR/vosk/libvosk.so $WORKDIR/../../src/main/jniLibs/$arch/libvosk.so

done


================================================
FILE: android/lib/build.gradle
================================================
def archiveName = "vosk-android"
def pomName = "Vosk Android"
def pomDescription = "Vosk speech recognition library for Android"

android {
    namespace 'org.vosk'
    compileSdkVersion 36
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 36
        versionCode 10
        versionName = version
        archivesBaseName = archiveName
        ndkVersion = "28.2.13676358"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

task buildVosk(type: Exec) {
    commandLine './build-vosk.sh'
    environment ANDROID_NDK_HOME: android.getNdkDirectory()
}

dependencies {
    api 'net.java.dev.jna:jna:5.18.1@aar'
}

//preBuild.dependsOn buildVosk

mavenPublishing {
    coordinates("com.alphacephei", archiveName, version)
    pom {
        name = pomName
        description = pomDescription
    }
}


================================================
FILE: android/lib/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest>
</manifest>

================================================
FILE: android/lib/src/main/java/org/vosk/LibVosk.java
================================================
package org.vosk;

import com.sun.jna.Native;
import com.sun.jna.Library;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

public class LibVosk {

    static {
        Native.register(LibVosk.class, "vosk");
    }

    public static native void vosk_set_log_level(int level);

    public static native Pointer vosk_model_new(String path);

    public static native void vosk_model_free(Pointer model);

    public static native Pointer vosk_spk_model_new(String path);

    public static native void vosk_spk_model_free(Pointer model);

    public static native Pointer vosk_recognizer_new(Model model, float sample_rate);

    public static native Pointer vosk_recognizer_new_spk(Pointer model, float sample_rate, Pointer spk_model);

    public static native Pointer vosk_recognizer_new_grm(Pointer model, float sample_rate, String grammar);

    public static native void vosk_recognizer_set_max_alternatives(Pointer recognizer, int max_alternatives);

    public static native void vosk_recognizer_set_words(Pointer recognizer, boolean words);

    public static native void vosk_recognizer_set_partial_words(Pointer recognizer, boolean partial_words);

    public static native void vosk_recognizer_set_spk_model(Pointer recognizer, Pointer spk_model);

    public static native boolean vosk_recognizer_accept_waveform(Pointer recognizer, byte[] data, int len);

    public static native boolean vosk_recognizer_accept_waveform_s(Pointer recognizer, short[] data, int len);

    public static native boolean vosk_recognizer_accept_waveform_f(Pointer recognizer, float[] data, int len);

    public static native String vosk_recognizer_result(Pointer recognizer);

    public static native String vosk_recognizer_final_result(Pointer recognizer);

    public static native String vosk_recognizer_partial_result(Pointer recognizer);

    public static native void vosk_recognizer_set_grm(Pointer recognizer, String grammar);

    public static native void vosk_recognizer_reset(Pointer recognizer);

    public static native void vosk_recognizer_set_endpointer_mode(Pointer recognizer, int mode);

    public static native void vosk_recognizer_set_endpointer_delays(Pointer recognizer, float t_start_max, float t_end, float t_max);

    public static native void vosk_recognizer_free(Pointer recognizer);

    public static native Pointer vosk_text_processor_new(String verbalizer, String tagger);

    public static native void vosk_text_processor_free(Pointer processor);

    public static native String vosk_text_processor_itn(Pointer processor, String input);

    /**
     * Set log level for Kaldi messages.
     *
     *  @param loglevel the level
     *     0 - default value to print info and error messages but no debug
     *     less than 0 - don't print info messages
     *     greater than 0 - more verbose mode
     */
    public static void setLogLevel(LogLevel loglevel) {
        vosk_set_log_level(loglevel.getValue());
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/LogLevel.java
================================================
package org.vosk;

public enum LogLevel {
    WARNINGS(-1),  // Print warning and errors
    INFO(0),       // Print info, along with warning and error messages, but no debug
    DEBUG(1);      // Print debug info

    private final int value;

    LogLevel(int value) {
        this.value = value;
    }

    public int getValue() {
        return this.value;
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/Model.java
================================================
package org.vosk;

import java.io.IOException;
import com.sun.jna.PointerType;

public class Model extends PointerType implements AutoCloseable {
    public Model() {
    }

    public Model(String path) throws IOException {
        super(LibVosk.vosk_model_new(path));

        if (getPointer() == null) {
            throw new IOException("Failed to create a model");
        }
    }

    @Override
    public void close() {
        LibVosk.vosk_model_free(this.getPointer());
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/Recognizer.java
================================================
package org.vosk;

import com.sun.jna.PointerType;
import java.io.IOException;

public class Recognizer extends PointerType implements AutoCloseable {
    /**
     * Creates the recognizer object.
     *
     * The recognizers process the speech and return text using shared model data
     * @param model       VoskModel containing static data for recognizer. Model can be
     *                    shared across recognizers, even running in different threads.
     * @param sampleRate The sample rate of the audio you are going to feed into the recognizer.
     *                    Make sure this rate matches the audio content, it is a common
     *                    issue causing accuracy problems.
     * @throws IOException if the recognizer could not be created
     */
    public Recognizer(Model model, float sampleRate) throws IOException {
        super(LibVosk.vosk_recognizer_new(model, sampleRate));

        if (getPointer() == null) {
            throw new IOException("Failed to create a recognizer");
        }
    }

    /**
     * Creates the recognizer object with speaker recognition.
     *
     *  With the speaker recognition mode the recognizer not just recognize
     *  text but also return speaker vectors one can use for speaker identification
     *
     *  @param model       VoskModel containing static data for recognizer. Model can be
     *                     shared across recognizers, even running in different threads.
     *  @param sampleRate The sample rate of the audio you are going to feed into the recognizer.
     *                     Make sure this rate matches the audio content, it is a common
     *                     issue causing accuracy problems.
     *  @param spkModel speaker model for speaker identification
     *  @throws IOException if the recognizer could not be created
     */
    public Recognizer(Model model, float sampleRate, SpeakerModel spkModel) throws IOException {
        super(LibVosk.vosk_recognizer_new_spk(model.getPointer(), sampleRate, spkModel.getPointer()));

        if (getPointer() == null) {
            throw new IOException("Failed to create a recognizer");
        }
    }

    /**
     * Creates the recognizer object with the phrase list.
     *
     *  Sometimes when you want to improve recognition accuracy and when you don't need
     *  to recognize large vocabulary you can specify a list of phrases to recognize. This
     *  will improve recognizer speed and accuracy but might return [unk] if user said
     *  something different.
     *
     *  Only recognizers with lookahead models support this type of quick configuration.
     *  Precompiled HCLG graph models are not supported.
     *
     *  @param model       VoskModel containing static data for recognizer. Model can be
     *                     shared across recognizers, even running in different threads.
     *  @param sampleRate The sample rate of the audio you are going to feed into the recognizer.
     *                     Make sure this rate matches the audio content, it is a common
     *                     issue causing accuracy problems.
     *  @param grammar The string with the list of phrases to recognize as JSON array of strings,
     *                 for example "["one two three four five", "[unk]"]".
     *  @throws IOException if the recognizer could not be created
     */
    public Recognizer(Model model, float sampleRate, String grammar) throws IOException {
        super(LibVosk.vosk_recognizer_new_grm(model.getPointer(), sampleRate, grammar));

        if (getPointer() == null) {
            throw new IOException("Failed to create a recognizer");
        }
    }

    /**
     * Configures recognizer to output n-best results.
     *
     * <pre>
     *   {
     *      "alternatives": [
     *          { "text": "one two three four five", "confidence": 0.97 },
     *          { "text": "one two three for five", "confidence": 0.03 },
     *      ]
     *   }
     * </pre>
     *
     * @param maxAlternatives - maximum alternatives to return from recognition results
     */
    public void setMaxAlternatives(int maxAlternatives) {
        LibVosk.vosk_recognizer_set_max_alternatives(this.getPointer(), maxAlternatives);
    }

    /** Enables words with times in the output
     *
     * <pre>
     *   "result" : [{
     *       "conf" : 1.000000,
     *       "end" : 1.110000,
     *       "start" : 0.870000,
     *       "word" : "what"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 1.530000,
     *       "start" : 1.110000,
     *       "word" : "zero"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 1.950000,
     *       "start" : 1.530000,
     *       "word" : "zero"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 2.340000,
     *       "start" : 1.950000,
     *       "word" : "zero"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 2.610000,
     *       "start" : 2.340000,
     *       "word" : "one"
     *     }],
     * </pre>
     *
     * @param words - boolean value
     */
    public void setWords(boolean words) {
        LibVosk.vosk_recognizer_set_words(this.getPointer(), words);
    }

    /**
     * Like above return words and confidences in partial results.
     *
     * @param partial_words - boolean value
     */
    public void setPartialWords(boolean partial_words) {
        LibVosk.vosk_recognizer_set_partial_words(this.getPointer(), partial_words);
    }

    /**
     * Adds speaker model to already initialized recognizer.
     *
     * Can add speaker recognition model to already created recognizer.
     * Helps to initialize speaker recognition for grammar-based recognizer.
     *
     * @param spkModel Speaker recognition model
     */
    public void setSpeakerModel(SpeakerModel spkModel) {
        LibVosk.vosk_recognizer_set_spk_model(this.getPointer(), spkModel.getPointer());
    }

    /**
     * Accept and process new chunk of voice data.
     *
     *  @param data - audio data in PCM 16-bit mono format
     *  @param len - length of the audio data
     *  @return 1 if silence is occurred and you can retrieve a new utterance with result method
     *           0 if decoding continues
     *           -1 if exception occurred
     */
    public boolean acceptWaveForm(byte[] data, int len) {
        return LibVosk.vosk_recognizer_accept_waveform(this.getPointer(), data, len);
    }

    public boolean acceptWaveForm(short[] data, int len) {
        return LibVosk.vosk_recognizer_accept_waveform_s(this.getPointer(), data, len);
    }

    public boolean acceptWaveForm(float[] data, int len) {
        return LibVosk.vosk_recognizer_accept_waveform_f(this.getPointer(), data, len);
    }

    /**
     * Returns speech recognition result
     *
     * @return the result in JSON format which contains decoded line, decoded
     *          words, times in seconds and confidences. You can parse this result
     *          with any json parser
     *
     * <pre>
     *  {
     *    "text" : "what zero zero zero one"
     *  }
     * </pre>
     *
     * If alternatives enabled it returns result with alternatives, see also #setMaxAlternatives().
     *
     * If word times enabled returns word time, see also #setWordTimes().
     */
    public String getResult() {
        return LibVosk.vosk_recognizer_result(this.getPointer());
    }

    /**
     * Returns partial speech recognition.
     *
     * @return partial speech recognition text which is not yet finalized.
     *          result may change as recognizer process more data.
     *
     * <pre>
     * {
     *    "partial" : "cyril one eight zero"
     * }
     * </pre>
     */
    public String getPartialResult() {
        return LibVosk.vosk_recognizer_partial_result(this.getPointer());
    }

    /**
     * Returns speech recognition result. Same as result, but doesn't wait for silence.
     *  You usually call it in the end of the stream to get final bits of audio. It
     *  flushes the feature pipeline, so all remaining audio chunks got processed.
     *
     *  @return speech result in JSON format.
     */
    public String getFinalResult() {
        return LibVosk.vosk_recognizer_final_result(this.getPointer());
    }

    /**
     * Reconfigures recognizer to use grammar.
     *
     * @param grammar      Set of phrases in JSON array of strings or "[]" to use default model graph.
     * @see #Recognizer(Model, float, String)
     */
    public void setGrammar(String grammar) {
        LibVosk.vosk_recognizer_set_grm(this.getPointer(), grammar);
    }

    /**
     * Resets the recognizer.
     * Resets current results so the recognition can continue from scratch.
     */
    public void reset() {
        LibVosk.vosk_recognizer_reset(this.getPointer());
    }

    /**
     * Endpointer delay mode
     */
    public class EndpointerMode {
        public static final int DEFAULT = 0;
        public static final int SHORT = 1;
        public static final int LONG = 2;
        public static final int VERY_LONG = 3;
    }

    /**
     * Configures endpointer mode for recognizer
     */
    public void setEndpointerMode(int mode) {
        LibVosk.vosk_recognizer_set_endpointer_mode(this.getPointer(), mode);
    }

    /**
     * Set endpointer delays
     *
     * @param t_start_max     timeout for stopping recognition in case of initial silence (usually around 5.0)
     * @param t_end           timeout for stopping recognition in milliseconds after we recognized something (usually around 0.5 - 1.0)
     * @param t_max           timeout for forcing utterance end in milliseconds (usually around 20-30)
     **/
    public void setEndpointerDelays(float t_start_max, float t_end, float t_max) {
        LibVosk.vosk_recognizer_set_endpointer_delays(this.getPointer(), t_start_max, t_end, t_max);
    }

    /**
     * Releases recognizer object.
     * Underlying model is also unreferenced and if needed, released.
     */
    @Override
    public void close() {
        LibVosk.vosk_recognizer_free(this.getPointer());
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/SpeakerModel.java
================================================
package org.vosk;

import com.sun.jna.PointerType;
import java.io.IOException;

/**
 * Helps to initialize speaker recognition for grammar-based recognizer.
 */
public class SpeakerModel extends PointerType implements AutoCloseable {
    public SpeakerModel() {
    }

    /**
     * Loads speaker model data from the file.
     *
     * The path must contain:
     * - a config file: mfcc.conf
     * - kaldi nnet: final.ext.raw
     * - mean.vec
     * - transform.mat
     *
     * @param path the path of the model on the filesystem
     * @throws IOException if the model could not be created
     *
     * @see <a href="http://kaldi-asr.org/doc/structkaldi_1_1MfccOptions.html">Kaldi MfccOptions</a>
     * @see <a href="http://kaldi-asr.org/doc/classkaldi_1_1nnet3_1_1Nnet.html">Kaldi Nnet</a>
     */
    public SpeakerModel(String path) throws IOException {
        super(LibVosk.vosk_spk_model_new(path));

        if (getPointer() == null) {
            throw new IOException("Failed to create a speaker model");
        }
    }

    @Override
    public void close() {
        LibVosk.vosk_spk_model_free(this.getPointer());
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/TextProcessor.java
================================================
package org.vosk;

import com.sun.jna.PointerType;

public class TextProcessor extends PointerType implements AutoCloseable {
    public TextProcessor() {
    }

    public TextProcessor(String verbalizer, String tagger) {
        super(LibVosk.vosk_text_processor_new(verbalizer, tagger));
    }

    @Override
    public void close() {
        LibVosk.vosk_text_processor_free(this.getPointer());
    }

    public String itn(String input) {
        return LibVosk.vosk_text_processor_itn(this.getPointer(), input);
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/android/RecognitionListener.java
================================================
// Copyright 2019 Alpha Cephei Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.vosk.android;

/**
 * Interface to receive recognition results
 */
public interface RecognitionListener {

    /**
     * Called when partial recognition result is available.
     */
    void onPartialResult(String hypothesis);

    /**
     * Called after silence occured.
     */
    void onResult(String hypothesis);

    /**
     * Called after stream end.
     */
    void onFinalResult(String hypothesis);

    /**
     * Called when an error occurs.
     */
    void onError(Exception exception);

    /**
     * Called after timeout expired
     */
    void onTimeout();
}


================================================
FILE: android/lib/src/main/java/org/vosk/android/SpeechService.java
================================================
// Copyright 2019 Alpha Cephei Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.vosk.android;

import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder.AudioSource;
import android.os.Handler;
import android.os.Looper;
import android.annotation.SuppressLint;

import org.vosk.Recognizer;
import java.io.IOException;

/**
 * Service that records audio in a thread, passes it to a recognizer and emits
 * recognition results. Recognition events are passed to a client using
 * {@link RecognitionListener}
 */
public class SpeechService {

    private final Recognizer recognizer;

    private final int sampleRate;
    private final static float BUFFER_SIZE_SECONDS = 0.2f;
    private final int bufferSize;
    private final AudioRecord recorder;

    private RecognizerThread recognizerThread;

    private final Handler mainHandler = new Handler(Looper.getMainLooper());

    /**
     * Creates speech service. Service holds the AudioRecord object, so you
     * need to call {@link #shutdown()} in order to properly finalize it.
     *
     * @throws IOException thrown if audio recorder can not be created for some reason.
     */
    @SuppressLint("MissingPermission")
    public SpeechService(Recognizer recognizer, float sampleRate) throws IOException {
        this.recognizer = recognizer;
        this.sampleRate = (int) sampleRate;

        bufferSize = Math.round(this.sampleRate * BUFFER_SIZE_SECONDS);
        recorder = new AudioRecord(
                AudioSource.VOICE_RECOGNITION, this.sampleRate,
                AudioFormat.CHANNEL_IN_MONO,
                AudioFormat.ENCODING_PCM_16BIT, bufferSize * 2);

        if (recorder.getState() == AudioRecord.STATE_UNINITIALIZED) {
            recorder.release();
            throw new IOException(
                    "Failed to initialize recorder. Microphone might be already in use.");
        }
    }


    /**
     * Starts recognition. Does nothing if recognition is active.
     *
     * @return true if recognition was actually started
     */
    public boolean startListening(RecognitionListener listener) {
        if (null != recognizerThread)
            return false;

        recognizerThread = new RecognizerThread(listener);
        recognizerThread.start();
        return true;
    }

    /**
     * Starts recognition. After specified timeout listening stops and the
     * endOfSpeech signals about that. Does nothing if recognition is active.
     * <p>
     * timeout - timeout in milliseconds to listen.
     *
     * @return true if recognition was actually started
     */
    public boolean startListening(RecognitionListener listener, int timeout) {
        if (null != recognizerThread)
            return false;

        recognizerThread = new RecognizerThread(listener, timeout);
        recognizerThread.start();
        return true;
    }

    private boolean stopRecognizerThread() {
        if (null == recognizerThread)
            return false;

        try {
            recognizerThread.interrupt();
            recognizerThread.join();
        } catch (InterruptedException e) {
            // Restore the interrupted status.
            Thread.currentThread().interrupt();
        }

        recognizerThread = null;
        return true;
    }

    /**
     * Stops recognition. Listener should receive final result if there is
     * any. Does nothing if recognition is not active.
     *
     * @return true if recognition was actually stopped
     */
    public boolean stop() {
        return stopRecognizerThread();
    }

    /**
     * Cancel recognition. Do not post any new events, simply cancel processing.
     * Does nothing if recognition is not active.
     *
     * @return true if recognition was actually stopped
     */
    public boolean cancel() {
        if (recognizerThread != null) {
            recognizerThread.setPause(true);
        }
        return stopRecognizerThread();
    }

    /**
     * Shutdown the recognizer and release the recorder
     */
    public void shutdown() {
        recorder.release();
    }

    public void setPause(boolean paused) {
        if (recognizerThread != null) {
            recognizerThread.setPause(paused);
        }
    }

    /**
     * Resets recognizer in a thread, starts recognition over again
     */
    public void reset() {
        if (recognizerThread != null) {
            recognizerThread.reset();
        }
    }

    private final class RecognizerThread extends Thread {

        private int remainingSamples;
        private final int timeoutSamples;
        private final static int NO_TIMEOUT = -1;
        private volatile boolean paused = false;
        private volatile boolean reset = false;

        RecognitionListener listener;

        public RecognizerThread(RecognitionListener listener, int timeout) {
            this.listener = listener;
            if (timeout != NO_TIMEOUT)
                this.timeoutSamples = timeout * sampleRate / 1000;
            else
                this.timeoutSamples = NO_TIMEOUT;
            this.remainingSamples = this.timeoutSamples;
        }

        public RecognizerThread(RecognitionListener listener) {
            this(listener, NO_TIMEOUT);
        }

        /**
         * When we are paused, don't process audio by the recognizer and don't emit
         * any listener results
         *
         * @param paused the status of pause
         */
        public void setPause(boolean paused) {
            this.paused = paused;
        }

        /**
         * Set reset state to signal reset of the recognizer and start over
         */
        public void reset() {
            this.reset = true;
        }

        @Override
        public void run() {

            recorder.startRecording();
            if (recorder.getRecordingState() == AudioRecord.RECORDSTATE_STOPPED) {
                recorder.stop();
                IOException ioe = new IOException(
                        "Failed to start recording. Microphone might be already in use.");
                mainHandler.post(() -> listener.onError(ioe));
            }

            short[] buffer = new short[bufferSize];

            while (!interrupted()
                    && ((timeoutSamples == NO_TIMEOUT) || (remainingSamples > 0))) {
                int nread = recorder.read(buffer, 0, buffer.length);

                if (paused) {
                    continue;
                }

                if (reset) {
                    recognizer.reset();
                    reset = false;
                }

                if (nread < 0)
                    throw new RuntimeException("error reading audio buffer");

                if (recognizer.acceptWaveForm(buffer, nread)) {
                    final String result = recognizer.getResult();
                    mainHandler.post(() -> listener.onResult(result));
                } else {
                    final String partialResult = recognizer.getPartialResult();
                    mainHandler.post(() -> listener.onPartialResult(partialResult));
                }

                if (timeoutSamples != NO_TIMEOUT) {
                    remainingSamples = remainingSamples - nread;
                }
            }

            recorder.stop();

            if (!paused) {
                // If we met timeout signal that speech ended
                if (timeoutSamples != NO_TIMEOUT && remainingSamples <= 0) {
                    mainHandler.post(() -> listener.onTimeout());
                } else {
                    final String finalResult = recognizer.getFinalResult();
                    mainHandler.post(() -> listener.onFinalResult(finalResult));
                }
            }

        }
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/android/SpeechStreamService.java
================================================
// Copyright 2019 Alpha Cephei Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.vosk.android;

import android.os.Handler;
import android.os.Looper;

import org.vosk.Recognizer;

import java.io.IOException;
import java.io.InputStream;

/**
 * Service that recognizes stream audio in a  thread, passes it to a recognizer and emits
 * recognition results. Recognition events are passed to a client using
 * {@link RecognitionListener}
 */
public class SpeechStreamService {

    private final Recognizer recognizer;
    private final InputStream inputStream;
    private final int sampleRate;
    private final static float BUFFER_SIZE_SECONDS = 0.2f;
    private final int bufferSize;

    private Thread recognizerThread;

    private final Handler mainHandler = new Handler(Looper.getMainLooper());

    /**
     * Creates speech service.
     **/
    public SpeechStreamService(Recognizer recognizer, InputStream inputStream, float sampleRate) {
        this.recognizer = recognizer;
        this.sampleRate = (int) sampleRate;
        this.inputStream = inputStream;
        bufferSize = Math.round(this.sampleRate * BUFFER_SIZE_SECONDS * 2);
    }

    /**
     * Starts recognition. Does nothing if recognition is active.
     *
     * @return true if recognition was actually started
     */
    public boolean start(RecognitionListener listener) {
        if (null != recognizerThread)
            return false;

        recognizerThread = new RecognizerThread(listener);
        recognizerThread.start();
        return true;
    }

    /**
     * Starts recognition. After specified timeout listening stops and the
     * endOfSpeech signals about that. Does nothing if recognition is active.
     * <p>
     * timeout - timeout in milliseconds to listen.
     *
     * @return true if recognition was actually started
     */
    public boolean start(RecognitionListener listener, int timeout) {
        if (null != recognizerThread)
            return false;

        recognizerThread = new RecognizerThread(listener, timeout);
        recognizerThread.start();
        return true;
    }

    /**
     * Stops recognition. All listeners should receive final result if there is
     * any. Does nothing if recognition is not active.
     *
     * @return true if recognition was actually stopped
     */
    public boolean stop() {
        if (null == recognizerThread)
            return false;

        try {
            recognizerThread.interrupt();
            recognizerThread.join();
        } catch (InterruptedException e) {
            // Restore the interrupted status.
            Thread.currentThread().interrupt();
        }

        recognizerThread = null;
        return true;
    }

    private final class RecognizerThread extends Thread {

        private int remainingSamples;
        private final int timeoutSamples;
        private final static int NO_TIMEOUT = -1;
        RecognitionListener listener;

        public RecognizerThread(RecognitionListener listener, int timeout) {
            this.listener = listener;
            if (timeout != NO_TIMEOUT)
                this.timeoutSamples = timeout * sampleRate / 1000;
            else
                this.timeoutSamples = NO_TIMEOUT;
            this.remainingSamples = this.timeoutSamples;
        }

        public RecognizerThread(RecognitionListener listener) {
            this(listener, NO_TIMEOUT);
        }

        @Override
        public void run() {

            byte[] buffer = new byte[bufferSize];

            while (!interrupted()
                    && ((timeoutSamples == NO_TIMEOUT) || (remainingSamples > 0))) {
                try {
                    int nread = inputStream.read(buffer, 0, buffer.length);
                    if (nread < 0) {
                        break;
                    } else {
                        boolean isSilence = recognizer.acceptWaveForm(buffer, nread);
                        if (isSilence) {
                            final String result = recognizer.getResult();
                            mainHandler.post(() -> listener.onResult(result));
                        } else {
                            final String partialResult = recognizer.getPartialResult();
                            mainHandler.post(() -> listener.onPartialResult(partialResult));
                        }
                    }

                    if (timeoutSamples != NO_TIMEOUT) {
                        remainingSamples = remainingSamples - nread;
                    }

                } catch (IOException e) {
                    mainHandler.post(() -> listener.onError(e));
                }
            }

            // If we met timeout signal that speech ended
            if (timeoutSamples != NO_TIMEOUT && remainingSamples <= 0) {
                mainHandler.post(() -> listener.onTimeout());
            } else {
                final String finalResult = recognizer.getFinalResult();
                mainHandler.post(() -> listener.onFinalResult(finalResult));
            }
        }
    }
}


================================================
FILE: android/lib/src/main/java/org/vosk/android/StorageService.java
================================================
// Copyright 2019 Alpha Cephei Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.vosk.android;

import android.content.Context;
import android.content.res.AssetManager;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import org.vosk.Model;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * Provides utility methods to sync model files to external storage to allow
 * C++ code access them. Relies on file named "uuid" to track updates.
 */
public class StorageService {

    protected static final String TAG = StorageService.class.getSimpleName();

    public interface Callback<R> {
        void onComplete(R result);
    }

    public static void unpack(Context context, String sourcePath, final String targetPath, final Callback<Model> completeCallback, final Callback<IOException> errorCallback) {
        Executor executor = Executors.newSingleThreadExecutor(); // change according to your requirements
        Handler handler = new Handler(Looper.getMainLooper());
        executor.execute(() -> {
            try {
                final String outputPath = sync(context, sourcePath, targetPath);
                Model model = new Model(outputPath);
                handler.post(() -> completeCallback.onComplete(model));
            } catch (final IOException e) {
                handler.post(() -> errorCallback.onComplete(e));
            }
        });
    }

    public static String sync(Context context, String sourcePath, String targetPath) throws IOException {

        AssetManager assetManager = context.getAssets();

        File externalFilesDir = context.getExternalFilesDir(null);
        if (externalFilesDir == null) {
            throw new IOException("cannot get external files dir, "
                    + "external storage state is " + Environment.getExternalStorageState());
        }

        File targetDir = new File(externalFilesDir, targetPath);
        String resultPath = new File(targetDir, sourcePath).getAbsolutePath();
        String sourceUUID = readLine(assetManager.open(sourcePath + "/uuid"));
        try {
            String targetUUID = readLine(new FileInputStream(new File(targetDir, sourcePath + "/uuid")));
            if (targetUUID.equals(sourceUUID)) return resultPath;
        } catch (FileNotFoundException e) {
            // ignore
        }
        deleteContents(targetDir);

        copyAssets(assetManager, sourcePath, targetDir);

        // Copy uuid
        copyFile(assetManager, sourcePath + "/uuid", targetDir);

        return resultPath;
    }

    private static String readLine(InputStream is) throws IOException {
        return new BufferedReader(new InputStreamReader(is)).readLine();
    }

    private static boolean deleteContents(File dir) {
        File[] files = dir.listFiles();
        boolean success = true;
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    success &= deleteContents(file);
                }
                if (!file.delete()) {
                    success = false;
                }
            }
        }
        return success;
    }

    private static void copyAssets(AssetManager assetManager, String path, File outPath) throws IOException {
        String[] assets = assetManager.list(path);
        if (assets == null) {
            return;
        }
        if (assets.length == 0) {
            if (!path.endsWith("uuid"))
                copyFile(assetManager, path, outPath);
        } else {
            File dir = new File(outPath, path);
            if (!dir.exists()) {
                Log.v(TAG, "Making directory " + dir.getAbsolutePath());
                if (!dir.mkdirs()) {
                    Log.v(TAG, "Failed to create directory " + dir.getAbsolutePath());
                }
            }
            for (String asset : assets) {
                copyAssets(assetManager, path + "/" + asset, outPath);
            }
        }
    }

    private static void copyFile(AssetManager assetManager, String fileName, File outPath) throws IOException {
        InputStream in;

        Log.v(TAG, "Copy " + fileName + " to " + outPath);
        in = assetManager.open(fileName);
        OutputStream out = new FileOutputStream(outPath + "/" + fileName);

        byte[] buffer = new byte[4000];
        int read;
        while ((read = in.read(buffer)) != -1) {
            out.write(buffer, 0, read);
        }
        in.close();
        out.close();
    }
}


================================================
FILE: android/lib/src/main/jniLibs/arm64-v8a/.keep-me
================================================


================================================
FILE: android/lib/src/main/jniLibs/armeabi-v7a/.keep-me
================================================


================================================
FILE: android/lib/src/main/jniLibs/x86/.keep-me
================================================


================================================
FILE: android/lib/src/main/jniLibs/x86_64/.keep-me
================================================


================================================
FILE: android/model-en/build.gradle
================================================
def archiveName = "vosk-model-en"
def pomName = "Vosk English Model"
def pomDescription = "Small English model for Android"

android {
    namespace "org.vosk"
    compileSdkVersion 36
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 36
        versionCode 10
        versionName = version
        archivesBaseName = archiveName
    }
    buildFeatures {
        buildConfig = false
    }
    sourceSets {
        main {
            assets.srcDirs += "$buildDir/generated/assets"
        }
    }
}

tasks.register('genUUID') {
    def uuid = UUID.randomUUID().toString()
    def odir = file("$buildDir/generated/assets/model-en-us")
    def ofile = file("$odir/uuid")
    doLast {
        mkdir odir
        ofile.text = uuid
    }
}

preBuild.dependsOn(genUUID)

mavenPublishing {
    coordinates("com.alphacephei", archiveName, version)
    pom {
        name = pomName
        description = pomDescription
    }
}


================================================
FILE: android/model-en/src/main/AndroidManifest.xml
================================================
<manifest>
</manifest>


================================================
FILE: android/settings.gradle
================================================
include ':lib', ':model-en'


================================================
FILE: c/Makefile
================================================
CFLAGS=-I../src
LDFLAGS=-L../src -lvosk -ldl -lpthread -Wl,-rpath,../src

all: test_vosk test_vosk_speaker

test_vosk: test_vosk.o
	gcc $^ -o $@ $(LDFLAGS)

test_vosk_speaker: test_vosk_speaker.o
	gcc $^ -o $@ $(LDFLAGS)

%.o: %.c
	gcc $(CFLAGS) -c -o $@ $<

clean:
	rm -f *.o *.a test_vosk test_vosk_speaker


================================================
FILE: c/test_vosk.c
================================================
#include <vosk_api.h>
#include <stdio.h>

int main() {
    FILE *wavin;
    char buf[3200];
    int nread, final;

    VoskModel *model = vosk_model_new("model");
    VoskRecognizer *recognizer = vosk_recognizer_new(model, 16000.0);

    wavin = fopen("test.wav", "rb");
    fseek(wavin, 44, SEEK_SET);
    while (!feof(wavin)) {
         nread = fread(buf, 1, sizeof(buf), wavin);
         final = vosk_recognizer_accept_waveform(recognizer, buf, nread);
         if (final) {
             printf("%s\n", vosk_recognizer_result(recognizer));
         } else {
             printf("%s\n", vosk_recognizer_partial_result(recognizer));
         }
    }
    printf("%s\n", vosk_recognizer_final_result(recognizer));

    vosk_recognizer_free(recognizer);
    vosk_model_free(model);
    fclose(wavin);
    return 0;
}


================================================
FILE: c/test_vosk_speaker.c
================================================
#include <vosk_api.h>
#include <stdio.h>

int main() {
    FILE *wavin;
    char buf[3200];
    int nread, final;

    VoskModel *model = vosk_model_new("model");
    VoskSpkModel *spk_model = vosk_spk_model_new("spk-model");
    VoskRecognizer *recognizer = vosk_recognizer_new_spk(model, 16000.0, spk_model);

    wavin = fopen("test.wav", "rb");
    fseek(wavin, 44, SEEK_SET);
    while (!feof(wavin)) {
         nread = fread(buf, 1, sizeof(buf), wavin);
         final = vosk_recognizer_accept_waveform(recognizer, buf, nread);
         if (final) {
             printf("%s\n", vosk_recognizer_result(recognizer));
         } else {
             printf("%s\n", vosk_recognizer_partial_result(recognizer));
         }
    }
    printf("%s\n", vosk_recognizer_final_result(recognizer));

    vosk_recognizer_free(recognizer);
    vosk_spk_model_free(spk_model);
    vosk_model_free(model);
    return 0;
}


================================================
FILE: csharp/README.md
================================================
This is a nuget-based wrapper for libvosk library

See demo folder for example how to use the library. You can simply run
"dotnet run" to run the demo. Make sure you unpacked the model and the
test file.

See the nuget folder for the sources of the wrapper. Run build.sh to
build nuget package.

Note we only support win64 and linux64 for now. No support for win32
since it is a little bit painful to load the libraries depending on
architecture. In theory we can add OSX some time or even Android.


================================================
FILE: csharp/demo/VoskDemo.cs
================================================
using System;
using System.IO;
using Vosk;

public class VoskDemo
{
   public static void DemoBytes(Model model)
   {
        // Demo byte buffer
        VoskRecognizer rec = new VoskRecognizer(model, 16000.0f);
        rec.SetMaxAlternatives(0);
        rec.SetWords(true);
        using(Stream source = File.OpenRead("test.wav")) {
            byte[] buffer = new byte[4096];
            int bytesRead;
            while((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0) {
                if (rec.AcceptWaveform(buffer, bytesRead)) {
                    Console.WriteLine(rec.Result());
                } else {
                    Console.WriteLine(rec.PartialResult());
                }
            }
        }
        Console.WriteLine(rec.FinalResult());
   }

   public static void DemoFloats(Model model)
   {
        // Demo float array
        VoskRecognizer rec = new VoskRecognizer(model, 16000.0f);

        rec.SetEndpointerMode(EndpointerMode.LONG);

        using(Stream source = File.OpenRead("test.wav")) {
            byte[] buffer = new byte[4096];
            int bytesRead;
            while((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0) {
                float[] fbuffer = new float[bytesRead / 2];
                for (int i = 0, n = 0; i < fbuffer.Length; i++, n+=2) {
                    fbuffer[i] = BitConverter.ToInt16(buffer, n);
                }
                if (rec.AcceptWaveform(fbuffer, fbuffer.Length)) {
                    Console.WriteLine(rec.Result());
                } else {
                    Console.WriteLine(rec.PartialResult());
                }
            }
        }
        Console.WriteLine(rec.FinalResult());
   }

   public static void DemoSpeaker(Model model)
   {
        // Output speakers
        SpkModel spkModel = new SpkModel("model-spk");
        VoskRecognizer rec = new VoskRecognizer(model, 16000.0f);
        rec.SetSpkModel(spkModel);

        using(Stream source = File.OpenRead("test.wav")) {
            byte[] buffer = new byte[4096];
            int bytesRead;
            while((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0) {
                if (rec.AcceptWaveform(buffer, bytesRead)) {
                    Console.WriteLine(rec.Result());
                } else {
                    Console.WriteLine(rec.PartialResult());
                }
            }
        }
        Console.WriteLine(rec.FinalResult());
   }

   public static void Main()
   {
        // You can set to -1 to disable logging messages
        Vosk.Vosk.SetLogLevel(0);

        Model model = new Model("model");
        DemoBytes(model);
        DemoFloats(model);
        DemoSpeaker(model);
   }
}


================================================
FILE: csharp/demo/VoskDemo.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>VoskDemo</RootNamespace>
  </PropertyGroup>

  <PropertyGroup>
    <RestoreSources>$(RestoreSources);../nuget</RestoreSources>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Vosk" Version="0.3.75" />
  </ItemGroup>

</Project>


================================================
FILE: csharp/nuget/Vosk.csproj
================================================
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PackageId>Vosk</PackageId>
    <Version>0.3.75</Version>
    <authors>Alpha Cephei Inc</authors>
    <owners>Alpha Cephei Inc</owners>
  </PropertyGroup>

  <Target Name="CopyFiles" AfterTargets="Build">
    <Copy SourceFiles="bin/Release/net8.0/Vosk.dll" DestinationFolder="lib/net8.0" />
  </Target>

</Project>


================================================
FILE: csharp/nuget/Vosk.nuspec
================================================
<?xml version="1.0"?>
<package>
  <metadata>
    <id>Vosk</id>
    <version>0.3.75</version>
    <authors>Alpha Cephei Inc</authors>
    <owners>Alpha Cephei Inc</owners>
    <license type="expression">Apache-2.0</license>
    <projectUrl>https://alphacephei.com/vosk/</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <title>Vosk Speech Recognition Toolkit</title>
    <description>Vosk is an offline open source speech recognition toolkit. It enables speech recognition models for 20+ languages and dialects - 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. More to come.

Vosk models are small (50 Mb) but provide continuous large vocabulary transcription, zero-latency response with streaming API, reconfigurable vocabulary and speaker identification.

Speech recognition bindings implemented for various programming languages like Python, Java, Node.JS, C#, C++ and others.

Vosk supplies speech recognition for chatbots, smart home appliances, virtual assistants. It can also create subtitles for movies, transcription for lectures and interviews.

Vosk scales from small devices like Raspberry Pi or Android smartphone to big clusters.</description>
    <releaseNotes>See for details https://github.com/alphacep/vosk-api/releases</releaseNotes>
    <repository type="git" url="https://github.com/alphacep/vosk-api.git" branch="master"/>
    <copyright>Copyright 2020-2050 Alpha Cephei Inc</copyright>
    <tags>speech recognition voice stt asr speech-to-text ai offline privacy</tags>
    <dependencies>
      <group targetFramework="net8.0"/>
    </dependencies>
  </metadata>
  <files>
    <file src="**" exclude="bin/**;obj/**;build.sh;src/*.cs;*.nupkg;**/.keep-me" />
  </files>
</package>


================================================
FILE: csharp/nuget/build/Vosk.targets
================================================
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <NativeLibs Include="$(MSBuildThisFileDirectory)\lib\linux-x64\*.so" Condition="'$([MSBuild]::IsOsPlatform(Linux))'" />
    <NativeLibs Include="$(MSBuildThisFileDirectory)\lib\win-x64\*.dll" Condition="'$([MSBuild]::IsOsPlatform(Windows))'" />
    <NativeLibs Include="$(MSBuildThisFileDirectory)\lib\osx-universal\*.dylib" Condition="'$([MSBuild]::IsOsPlatform(OSX))'" />
    <None Include="@(NativeLibs)">
      <Link>%(FileName)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>


================================================
FILE: csharp/nuget/build/lib/linux-x64/.keep-me
================================================


================================================
FILE: csharp/nuget/build/lib/osx-universal/.keep-me
================================================


================================================
FILE: csharp/nuget/build/lib/win-x64/.keep-me
================================================


================================================
FILE: csharp/nuget/build.sh
================================================
rm -rf bin lib obj
/home/shmyrev/local/dotnet/dotnet pack Vosk.csproj -p:NuspecFile=Vosk.nuspec -o .


================================================
FILE: csharp/nuget/src/BatchModel.cs
================================================
using System;

namespace Vosk
{
    public class BatchModel : global::System.IDisposable
    {
        private global::System.Runtime.InteropServices.HandleRef handle;

        internal BatchModel(global::System.IntPtr cPtr)
        {
            handle = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
        }

        internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BatchModel obj)
        {
            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.handle;
        }

        ~BatchModel()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            global::System.GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            lock (this)
            {
                if (handle.Handle != global::System.IntPtr.Zero)
                {
                    VoskPINVOKE.delete_BatchModel(handle);
                    handle = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
                }
            }
        }

        public BatchModel(string model_path) : this(VoskPINVOKE.new_BatchModel(model_path))
        {
        }

        public void WaitForCompletion()
        {
            if (handle.Handle != global::System.IntPtr.Zero)
            {
                VoskPINVOKE.wait_BatchModel(handle);
            }
        }
    }

}

================================================
FILE: csharp/nuget/src/Model.cs
================================================
namespace Vosk {

public class Model : global::System.IDisposable {
  private global::System.Runtime.InteropServices.HandleRef handle;

  internal Model(global::System.IntPtr cPtr) {
    handle = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
  }

  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Model obj) {
    return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.handle;
  }

  ~Model() {
    Dispose(false);
  }

  public void Dispose() {
    Dispose(true);
    global::System.GC.SuppressFinalize(this);
  }

  protected virtual void Dispose(bool disposing) {
    lock(this) {
      if (handle.Handle != global::System.IntPtr.Zero) {
        VoskPINVOKE.delete_Model(handle);
        handle = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
    }
  }

  public Model(string model_path) : this(VoskPINVOKE.new_Model(model_path)) {
  }

  public int FindWord(string word) {
    return VoskPINVOKE.Model_vosk_model_find_word(handle, word);
  }

}

}


================================================
FILE: csharp/nuget/src/SpkModel.cs
================================================
namespace Vosk {

public class SpkModel : global::System.IDisposable {
  private global::System.Runtime.InteropServices.HandleRef handle;

  internal SpkModel(global::System.IntPtr cPtr) {
    handle = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
  }

  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SpkModel obj) {
    return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.handle;
  }

  ~SpkModel() {
    Dispose(false);
  }

  public void Dispose() {
    Dispose(true);
    global::System.GC.SuppressFinalize(this);
  }

  protected virtual void Dispose(bool disposing) {
    lock(this) {
      if (handle.Handle != global::System.IntPtr.Zero) {
        VoskPINVOKE.delete_SpkModel(handle);
        handle = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
    }
  }

  public SpkModel(string model_path) : this(VoskPINVOKE.new_SpkModel(model_path)) {
  }

}

}


================================================
FILE: csharp/nuget/src/Vosk.cs
================================================
namespace Vosk {

public class Vosk {
  public static void SetLogLevel(int level) {
    VoskPINVOKE.SetLogLevel(level);
  }

  public static void GpuInit() {
    VoskPINVOKE.GpuInit();
  }

  public static void GpuThreadInit() {
    VoskPINVOKE.GpuThreadInit();
  }
}

}


================================================
FILE: csharp/nuget/src/VoskBatchRecognizer.cs
================================================
using System;

namespace Vosk
{
    public class VoskBatchRecognizer : System.IDisposable
    {
        private System.Runtime.InteropServices.HandleRef handle;

        internal VoskBatchRecognizer(System.IntPtr cPtr)
        {
            handle = new System.Runtime.InteropServices.HandleRef(this, cPtr);
        }

        internal static System.Runtime.InteropServices.HandleRef getCPtr(VoskBatchRecognizer obj)
        {
            return (obj == null) ? new System.Runtime.InteropServices.HandleRef(null, System.IntPtr.Zero) : obj.handle;
        }

        ~VoskBatchRecognizer()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            lock (this)
            {
                if (handle.Handle != System.IntPtr.Zero)
                {
                    VoskPINVOKE.delete_VoskBatchRecognizer(handle);
                    handle = new System.Runtime.InteropServices.HandleRef(null, System.IntPtr.Zero);
                }
            }
        }

        public VoskBatchRecognizer(BatchModel model, float sample_rate) : this(VoskPINVOKE.new_VoskBatchRecognizer(BatchModel.getCPtr(model), sample_rate))
        {
        }

        public bool AcceptWaveform(byte[] data, int len)
        {
            return VoskPINVOKE.VoskBatchRecognizer_AcceptWaveform(handle, data, len);
        }

        private static string PtrToStringUTF8(System.IntPtr ptr)
        {
            int len = 0;
            while (System.Runtime.InteropServices.Marshal.ReadByte(ptr, len) != 0)
                len++;
            byte[] array = new byte[len];
            System.Runtime.InteropServices.Marshal.Copy(ptr, array, 0, len);
            return System.Text.Encoding.UTF8.GetString(array);
        }

        public string FrontResult()
        {
            return PtrToStringUTF8(VoskPINVOKE.VoskBatchRecognizer_FrontResult(handle));
        }

        public string Result()
        {
            string result = PtrToStringUTF8(VoskPINVOKE.VoskBatchRecognizer_FrontResult(handle));
            VoskPINVOKE.VoskBatchRecognizer_Pop(handle);
            return result;
        }

        public int GetNumPendingChunks()
        {
            return VoskPINVOKE.VoskBatchRecognizer_GetPendingChunks(handle);
        }

        public void FinishStream()
        {
            VoskPINVOKE.VoskBatchRecognizer_FinishStream(handle);
        }

        public void SetNLSML(bool nlsml)
        {
            VoskPINVOKE.VoskBatchRecognizer_SetNLSML(handle, Convert.ToInt32(nlsml));
        }
    }
}


================================================
FILE: csharp/nuget/src/VoskPINVOKE.cs
================================================
namespace Vosk {

class VoskPINVOKE {

  static VoskPINVOKE() {
  }

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_model_new")]
  public static extern global::System.IntPtr new_Model(string jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_model_free")]
  public static extern void delete_Model(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_model_find_word")]
  public static extern int Model_vosk_model_find_word(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_spk_model_new")]
  public static extern global::System.IntPtr new_SpkModel(string jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_spk_model_free")]
  public static extern void delete_SpkModel(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_new")]
  public static extern global::System.IntPtr new_VoskRecognizer(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_new_spk")]
  public static extern global::System.IntPtr new_VoskRecognizerSpk(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_new_grm")]
  public static extern global::System.IntPtr new_VoskRecognizerGrm(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, string jarg3);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_free")]
  public static extern void delete_VoskRecognizer(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_set_max_alternatives")]
  public static extern void VoskRecognizer_SetMaxAlternatives(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_set_words")]
  public static extern void VoskRecognizer_SetWords(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_set_partial_words")]
  public static extern void VoskRecognizer_SetPartialWords(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_set_spk_model")]
  public static extern void VoskRecognizer_SetSpkModel(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_accept_waveform")]
  public static extern bool VoskRecognizer_AcceptWaveform(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]byte[] jarg2, int jarg3);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_accept_waveform_s")]
  public static extern bool VoskRecognizer_AcceptWaveformShort(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]short[] jarg2, int jarg3);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_accept_waveform_f")]
  public static extern bool VoskRecognizer_AcceptWaveformFloat(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)]float[] jarg2, int jarg3);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_result")]
  public static extern global::System.IntPtr VoskRecognizer_Result(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_partial_result")]
  public static extern global::System.IntPtr VoskRecognizer_PartialResult(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_final_result")]
  public static extern global::System.IntPtr VoskRecognizer_FinalResult(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_reset")]
  public static extern void VoskRecognizer_Reset(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_set_endpointer_mode")]
  public static extern void VoskRecognizer_SetEndpointerMode(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_recognizer_set_endpointer_delays")]
  public static extern void VoskRecognizer_SetEndpointerDelays(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2, float jarg3, float jarg4);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_set_log_level")]
  public static extern void SetLogLevel(int jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_gpu_init")]
  public static extern void GpuInit();

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint="vosk_gpu_thread_init")]
  public static extern void GpuThreadInit();

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_model_new")]
  public static extern global::System.IntPtr new_BatchModel(string jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_model_free")]
  public static extern void delete_BatchModel(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_model_wait")]
  public static extern void wait_BatchModel(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_new")]
  public static extern global::System.IntPtr new_VoskBatchRecognizer(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_free")]
  public static extern void delete_VoskBatchRecognizer(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_accept_waveform")]
  public static extern bool VoskBatchRecognizer_AcceptWaveform(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] byte[] jarg2, int jarg3);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_set_nlsml")]
  public static extern void VoskBatchRecognizer_SetNLSML(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_finish_stream")]
  public static extern void VoskBatchRecognizer_FinishStream(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_front_result")]
  public static extern global::System.IntPtr VoskBatchRecognizer_FrontResult(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_pop")]
  public static extern void VoskBatchRecognizer_Pop(global::System.Runtime.InteropServices.HandleRef jarg1);

  [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoint = "vosk_batch_recognizer_get_pending_chunks")]
  public static extern int VoskBatchRecognizer_GetPendingChunks(global::System.Runtime.InteropServices.HandleRef jarg1);

}

}


================================================
FILE: csharp/nuget/src/VoskRecognizer.cs
================================================
namespace Vosk {

public enum EndpointerMode {
    DEFAULT = 0,
    SHORT = 1,
    LONG = 2,
    VERY_LONG = 3
}

public class VoskRecognizer : System.IDisposable {
  private System.Runtime.InteropServices.HandleRef handle;

  internal VoskRecognizer(System.IntPtr cPtr) {
    handle = new System.Runtime.InteropServices.HandleRef(this, cPtr);
  }

  internal static System.Runtime.InteropServices.HandleRef getCPtr(VoskRecognizer obj) {
    return (obj == null) ? new System.Runtime.InteropServices.HandleRef(null, System.IntPtr.Zero) : obj.handle;
  }

  ~VoskRecognizer() {
    Dispose(false);
  }

  public void Dispose() {
    Dispose(true);
    System.GC.SuppressFinalize(this);
  }

  protected virtual void Dispose(bool disposing) {
    lock(this) {
      if (handle.Handle != System.IntPtr.Zero) {
        VoskPINVOKE.delete_VoskRecognizer(handle);
        handle = new System.Runtime.InteropServices.HandleRef(null, System.IntPtr.Zero);
      }
    }
  }

  public VoskRecognizer(Model model, float sample_rate) : this(VoskPINVOKE.new_VoskRecognizer(Model.getCPtr(model), sample_rate)) {
  }

  public VoskRecognizer(Model model, float sample_rate, SpkModel spk_model) : this(VoskPINVOKE.new_VoskRecognizerSpk(Model.getCPtr(model), sample_rate, SpkModel.getCPtr(spk_model))) {
  }

  public VoskRecognizer(Model model, float sample_rate, string grammar) : this(VoskPINVOKE.new_VoskRecognizerGrm(Model.getCPtr(model), sample_rate, grammar)) {
  }

  public void SetMaxAlternatives(int max_alternatives) {
    VoskPINVOKE.VoskRecognizer_SetMaxAlternatives(handle, max_alternatives);
  }

  public void SetWords(bool words) {
    VoskPINVOKE.VoskRecognizer_SetWords(handle, words ? 1 : 0);
  }

  public void SetPartialWords(bool partial_words) {
    VoskPINVOKE.VoskRecognizer_SetPartialWords(handle, partial_words ? 1 : 0);
  }

  public void SetSpkModel(SpkModel spk_model) {
    VoskPINVOKE.VoskRecognizer_SetSpkModel(handle, SpkModel.getCPtr(spk_model));
  }

  public bool AcceptWaveform(byte[] data, int len) {
    return VoskPINVOKE.VoskRecognizer_AcceptWaveform(handle, data, len);
  }

  public bool AcceptWaveform(short[] sdata, int len) {
    return VoskPINVOKE.VoskRecognizer_AcceptWaveformShort(handle, sdata, len);
  }

  public bool AcceptWaveform(float[] fdata, int len) {
    return VoskPINVOKE.VoskRecognizer_AcceptWaveformFloat(handle, fdata, len);
  }

  private static string PtrToStringUTF8(System.IntPtr ptr) {
    int len = 0;
    while (System.Runtime.InteropServices.Marshal.ReadByte(ptr, len) != 0)
        len++;
    byte[] array = new byte[len];
    System.Runtime.InteropServices.Marshal.Copy(ptr, array, 0, len);
    return System.Text.Encoding.UTF8.GetString(array);
  }

  public string Result() {
    return PtrToStringUTF8(VoskPINVOKE.VoskRecognizer_Result(handle));
  }

  public string PartialResult() {
    return PtrToStringUTF8(VoskPINVOKE.VoskRecognizer_PartialResult(handle));
  }

  public string FinalResult() {
    return PtrToStringUTF8(VoskPINVOKE.VoskRecognizer_FinalResult(handle));
  }

  public void Reset() {
    VoskPINVOKE.VoskRecognizer_Reset(handle);
  }

  public void SetEndpointerMode(EndpointerMode mode) {
    VoskPINVOKE.VoskRecognizer_SetEndpointerMode(handle, (int) mode);
  }

  public void SetEndpointerDelays(float t_start_max, float t_end, float t_max) {
    VoskPINVOKE.VoskRecognizer_SetEndpointerDelays(handle, t_start_max, t_end, t_max);
  }

}

}


================================================
FILE: go/COPYING
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. this License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS


================================================
FILE: go/README.md
================================================
See example subfolder for instructions how to use the module


================================================
FILE: go/batch.go
================================================
package vosk

// #cgo CPPFLAGS: -I ${SRCDIR}/../src
// #cgo !windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -ldl -lpthread
// #cgo windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -lpthread
// #include <stdlib.h>
// #include <vosk_api.h>
import "C"
import "unsafe"

// VoskBatchModel contains a reference to the C VoskBatchModel
type VoskBatchModel struct {
	model *C.struct_VoskBatchModel
}

// NewBatchModel creates a new VoskBatchModel instance
func NewBatchModel(modelPath string) (*VoskBatchModel, error) {
	cmodelPath := C.CString(modelPath)
	defer C.free(unsafe.Pointer(cmodelPath))
	internal := C.vosk_batch_model_new(cmodelPath)
	model := &VoskBatchModel{model: internal}
	return model, nil
}

func (m *VoskBatchModel) Free() {
	C.vosk_batch_model_free(m.model)
}

func (m *VoskBatchModel) Wait() {
	C.vosk_batch_model_wait(m.model);
}

func freeBatchModel(model *VoskBatchModel) {
	C.vosk_batch_model_free(model.model)
}

// VoskBatchRecognizer contains a reference to the C VoskBatchRecognizer
type VoskBatchRecognizer struct {
	rec *C.struct_VoskBatchRecognizer
}

func freeBatchRecognizer(recognizer *VoskBatchRecognizer) {
	C.vosk_batch_recognizer_free(recognizer.rec)
}

func (r *VoskBatchRecognizer) Free() {
	C.vosk_batch_recognizer_free(r.rec)
}

// NewBatchRecognizer creates a new VoskBatchRecognizer instance
func NewBatchRecognizer(model *VoskBatchModel, sampleRate float64) (*VoskBatchRecognizer, error) {
	internal := C.vosk_batch_recognizer_new(model.model, C.float(sampleRate))
	rec := &VoskBatchRecognizer{rec: internal}
	return rec, nil
}

// AcceptWaveform accepts and processes a new chunk of the voice data.
func (r *VoskBatchRecognizer) AcceptWaveform(buffer []byte) {
	cbuf := C.CBytes(buffer)
	defer C.free(cbuf)
	C.vosk_batch_recognizer_accept_waveform(r.rec, (*C.char)(cbuf), C.int(len(buffer)))
}

/** Set NLSML output
 * @param nlsml - boolean value
 */
//void vosk_batch_recognizer_set_nlsml(VoskBatchRecognizer *recognizer, int nlsml);

func (r *VoskBatchRecognizer) SetNlsml(nlsml int) {
	C.vosk_batch_recognizer_set_nlsml(r.rec, C.int(nlsml))
}

/** Closes the stream */
//void vosk_batch_recognizer_finish_stream(VoskBatchRecognizer *recognizer);

func (r *VoskBatchRecognizer) FinishStream() {
	C.vosk_batch_recognizer_finish_stream(r.rec)
}

/** Return results */
//const char *vosk_batch_recognizer_front_result(VoskBatchRecognizer *recognizer);

func (r *VoskBatchRecognizer) FrontResult() string {
	return C.GoString(C.vosk_batch_recognizer_front_result(r.rec))
}

/** Release and free first retrieved result */
//void vosk_batch_recognizer_pop(VoskBatchRecognizer *recognizer);

func (r *VoskBatchRecognizer) Pop() {
	C.vosk_batch_recognizer_pop(r.rec)
}

/** Get amount of pending chunks for more intelligent waiting */
//int vosk_batch_recognizer_get_pending_chunks(VoskBatchRecognizer *recognizer);
func (r *VoskBatchRecognizer) GetPendingChunks() int {
	i := C.vosk_batch_recognizer_get_pending_chunks(r.rec)
	return int(i)
}


================================================
FILE: go/batch_example/README.md
================================================
This example expects a `s16le` converted audio file and converts it to text in a
manner that imitates the Python example of [test_gpu_batch.py](../python/example/test_gpu_batch.py).

Note that the `libvosk.so` must be in the library path. This was successfully tested on
Ubuntu 24.04 with Go 1.18, gcc-11, NVIDIA driver 570.172.08.


================================================
FILE: go/batch_example/test_batch.go
================================================
package main

import (
	"flag"
	"fmt"
	"io"
	"log"
	"os"

	vosk "github.com/alphacep/vosk-api/go"
)

func main() {
	var filename string
	flag.StringVar(&filename, "f", "", "file to transcribe")
	flag.Parse()

	vosk.GPUInit()

	model, err := vosk.NewBatchModel("model")
	if err != nil {
		log.Fatal(err)
	}

	rec, err := vosk.NewBatchRecognizer(model, 16000.0)
	if err != nil {
		log.Fatal(err)
	}

	file, err := os.Open(filename)
	if err != nil {
		panic(err)
	}
	defer file.Close()

	buf := make([]byte, 8000)

	for {
		if _, err := file.Read(buf); err != nil {
			if err != io.EOF {
				log.Fatal(err)
			}

			break
		}
		rec.AcceptWaveform(buf)
		model.Wait()
		if rec.FrontResult() != "" {
			fmt.Println(rec.FrontResult())
			rec.Pop()
		}
	}
	// Is this needed? rec.FinishStream()
}


================================================
FILE: go/doc.go
================================================
// Go bindings for Vosk speech recognition toolkit. Vosk is an offline
// open source speech to text API for Android, iOS, Raspberry Pi and
// servers. It enables speech recognition models for 18 languages and
// dialects - English, Indian English, German, French, Spanish, Portuguese,
// Chinese, Russian, Turkish, Vietnamese, Italian, Dutch, Catalan, Arabic,
// Greek, Farsi, Filipino, Ukrainian.
package vosk


================================================
FILE: go/example/README.md
================================================
To try this package do the following steps:

On Linux (we download library and set LD_LIBRARY_PATH)

```
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
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`/vosk-linux-x86_64-0.3.45 LD_LIBRARY_PATH=$VOSK_PATH CGO_CPPFLAGS="-I $VOSK_PATH" CGO_LDFLAGS="-L $VOSK_PATH" go run . -f test.wav
```

for Windows (we place DLLs in current folder where linker finds them):

```
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
```


================================================
FILE: go/example/doc.go
================================================
// Example package for Vosk Go bindings.
package main


================================================
FILE: go/example/test_simple.go
================================================
package main

import (
	"encoding/json"
	"flag"
	"fmt"
	"io"
	"log"
	"os"

	vosk "github.com/alphacep/vosk-api/go"
)

func main() {
	var filename string
	flag.StringVar(&filename, "f", "", "file to transcribe")
	flag.Parse()

	vosk.GPUInit()

	model, err := vosk.NewModel("model")
	if err != nil {
		log.Fatal(err)
	}

	// we can check if word is in the vocabulary
	// fmt.Println(model.FindWord("air"))

	sampleRate := 16000.0
	rec, err := vosk.NewRecognizer(model, sampleRate)
	if err != nil {
		log.Fatal(err)
	}
	rec.SetWords(1)

	file, err := os.Open(filename)
	if err != nil {
		panic(err)
	}
	defer file.Close()

	buf := make([]byte, 4096)

	for {
		_, err := file.Read(buf)
		if err != nil {
			if err != io.EOF {
				log.Fatal(err)
			}

			break
		}

		if rec.AcceptWaveform(buf) != 0 {
			fmt.Println(rec.Result())
		}
	}

	// Unmarshal example for final result
	var jres map[string]interface{}
	json.Unmarshal([]byte(rec.FinalResult()), &jres)
	fmt.Println(jres["text"])
}


================================================
FILE: go/go.mod
================================================
module github.com/alphacep/vosk-api/go

go 1.16

replace (
    github.com/alphacep/vosk-api/go => ./
)


================================================
FILE: go/vosk.go
================================================
package vosk

// #cgo CPPFLAGS: -I ${SRCDIR}/../src
// #cgo !windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -ldl -lpthread
// #cgo windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -lpthread
// #include <stdlib.h>
// #include <vosk_api.h>
import "C"
import "unsafe"

// VoskModel contains a reference to the C VoskModel
type VoskModel struct {
	model *C.struct_VoskModel
}

// NewModel creates a new VoskModel instance
func NewModel(modelPath string) (*VoskModel, error) {
	cmodelPath := C.CString(modelPath)
	defer C.free(unsafe.Pointer(cmodelPath))
	internal := C.vosk_model_new(cmodelPath)
	model := &VoskModel{model: internal}
	return model, nil
}

func (m *VoskModel) Free() {
	C.vosk_model_free(m.model)
}

func freeModel(model *VoskModel) {
	C.vosk_model_free(model.model)
}

// FindWord checks if a word can be recognized by the model.
// Returns the word symbol if the word exists inside the model or
// -1 otherwise.
func (m *VoskModel) FindWord(word string) int {
	cstr := C.CString(word)
	defer C.free(unsafe.Pointer(cstr))
	i := C.vosk_model_find_word(m.model, cstr)
	return int(i)
}

// VoskSpkModel contains a reference to the C VoskSpkModel
type VoskSpkModel struct {
	spkModel *C.struct_VoskSpkModel
}

// NewSpkModel creates a new VoskSpkModel instance
func NewSpkModel(spkModelPath string) (*VoskSpkModel, error) {
	cspkModelPath := C.CString(spkModelPath)
	defer C.free(unsafe.Pointer(cspkModelPath))
	internal := C.vosk_spk_model_new(cspkModelPath)
	spkModel := &VoskSpkModel{spkModel: internal}
	return spkModel, nil
}

func freeSpkModel(model *VoskSpkModel) {
	C.vosk_spk_model_free(model.spkModel)
}

func(s *VoskSpkModel) Free() {
	C.vosk_spk_model_free(s.spkModel)
}

// VoskRecognizer contains a reference to the C VoskRecognizer
type VoskRecognizer struct {
	rec *C.struct_VoskRecognizer
}

func freeRecognizer(recognizer *VoskRecognizer) {
	C.vosk_recognizer_free(recognizer.rec)
}

func (r *VoskRecognizer) Free() {
	C.vosk_recognizer_free(r.rec)
}

// NewRecognizer creates a new VoskRecognizer instance
func NewRecognizer(model *VoskModel, sampleRate float64) (*VoskRecognizer, error) {
	internal := C.vosk_recognizer_new(model.model, C.float(sampleRate))
	rec := &VoskRecognizer{rec: internal}
	return rec, nil
}

// NewRecognizerSpk creates a new VoskRecognizer instance with a speaker model.
func NewRecognizerSpk(model *VoskModel, sampleRate float64, spkModel *VoskSpkModel) (*VoskRecognizer, error) {
	internal := C.vosk_recognizer_new_spk(model.model, C.float(sampleRate), spkModel.spkModel)
	rec := &VoskRecognizer{rec: internal}
	return rec, nil
}

// NewRecognizerGrm creates a new VoskRecognizer instance with the phrase list.
func NewRecognizerGrm(model *VoskModel, sampleRate float64, grammar string) (*VoskRecognizer, error) {
	cgrammar := C.CString(grammar)
	defer C.free(unsafe.Pointer(cgrammar))
	internal := C.vosk_recognizer_new_grm(model.model, C.float(sampleRate), cgrammar)
	rec := &VoskRecognizer{rec: internal}
	return rec, nil
}

// SetSpkModel adds a speaker model to an already initialized recognizer.
func (r *VoskRecognizer) SetSpkModel(spkModel *VoskSpkModel) {
	C.vosk_recognizer_set_spk_model(r.rec, spkModel.spkModel)
}

// SetGrm sets which phrases to recognize on an already initialized recognizer.
func (r *VoskRecognizer) SetGrm(grammar string) {
	cgrammar := C.CString(grammar)
	defer C.free(unsafe.Pointer(cgrammar))
	C.vosk_recognizer_set_grm(r.rec, cgrammar)
}

// SetMaxAlternatives configures the recognizer to output n-best results.
func (r *VoskRecognizer) SetMaxAlternatives(maxAlternatives int) {
	C.vosk_recognizer_set_max_alternatives(r.rec, C.int(maxAlternatives))
}

// SetWords enables words with times in the ouput.
func (r *VoskRecognizer) SetWords(words int) {
	C.vosk_recognizer_set_words(r.rec, C.int(words))
}

// SetPartialWords enables words with times in the partial ouput.
func (r *VoskRecognizer) SetPartialWords(words int) {
	C.vosk_recognizer_set_partial_words(r.rec, C.int(words))
}

// SetEndpointerDelays sets the recognition timeouts, where startMax
// is the timeout for stopping recognition in case of initial silence
// (usually around 5), end is the timeout for stopping recognition
// in milliseconds after we recognized something (usually around 0.5-1.0),
// and max is the timeout for forcing utterance end in milliseconds
// (usually around 20-30).
func (r *VoskRecognizer) SetEndpointerDelays(startMax, end, max float64) {
	C.vosk_recognizer_set_endpointer_delays(r.rec, C.float(startMax), C.float(end), C.float(max))
}

// AcceptWaveform accepts and processes a new chunk of the voice data.
func (r *VoskRecognizer) AcceptWaveform(buffer []byte) int {
	cbuf := C.CBytes(buffer)
	defer C.free(cbuf)
	i := C.vosk_recognizer_accept_waveform(r.rec, (*C.char)(cbuf), C.int(len(buffer)))
	return int(i)
}

// Result returns a speech recognition result.
func (r *VoskRecognizer) Result() string {
	return C.GoString(C.vosk_recognizer_result(r.rec))
}

// PartialResult returns a partial speech recognition result.
func (r *VoskRecognizer) PartialResult() string {
	return C.GoString(C.vosk_recognizer_partial_result(r.rec))
}

// FinalResult returns a speech recognition result. Same as result, but doesn't wait
// for silence.
func (r *VoskRecognizer) FinalResult() string {
	return C.GoString(C.vosk_recognizer_final_result(r.rec))
}

// Reset resets the recognizer.
func (r *VoskRecognizer) Reset() {
	C.vosk_recognizer_reset(r.rec)
}

// SetLogLevel sets the log level for Kaldi messages.
func SetLogLevel(logLevel int) {
	C.vosk_set_log_level(C.int(logLevel))
}

// GPUInit automatically selects a CUDA device and allows multithreading.
func GPUInit() {
	C.vosk_gpu_init()
}

// GPUThreadInit inits CUDA device in a multi-threaded environment.
func GPUThreadInit() {
	C.vosk_gpu_thread_init()
}


================================================
FILE: ios/README
================================================
This is a baseline for the vosk-api iOS demo. It requires a build of a
Vosk-API library, mail contact@alphacephei.com for the details.



================================================
FILE: ios/VoskApiTest/AppDelegate.swift
================================================
//
//  AppDelegate.swift
//  VoskApiTest
//
//  Created by Niсkolay Shmyrev on 01.03.20.
//  Copyright © 2020 Alpha Cephei. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}



================================================
FILE: ios/VoskApiTest/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
  "images" : [
    {
      "idiom" : "iphone",
      "size" : "20x20",
      "scale" : "2x"
    },
    {
      "idiom" : "iphone",
      "size" : "20x20",
      "scale" : "3x"
    },
    {
      "idiom" : "iphone",
      "size" : "29x29",
      "scale" : "2x"
    },
    {
      "idiom" : "iphone",
      "size" : "29x29",
      "scale" : "3x"
    },
    {
      "idiom" : "iphone",
      "size" : "40x40",
      "scale" : "2x"
    },
    {
      "idiom" : "iphone",
      "size" : "40x40",
      "scale" : "3x"
    },
    {
      "idiom" : "iphone",
      "size" : "60x60",
      "scale" : "2x"
    },
    {
      "idiom" : "iphone",
      "size" : "60x60",
      "scale" : "3x"
    },
    {
      "idiom" : "ipad",
      "size" : "20x20",
      "scale" : "1x"
    },
    {
      "idiom" : "ipad",
      "size" : "20x20",
      "scale" : "2x"
    },
    {
      "idiom" : "ipad",
      "size" : "29x29",
      "scale" : "1x"
    },
    {
      "idiom" : "ipad",
      "size" : "29x29",
      "scale" : "2x"
    },
    {
      "idiom" : "ipad",
      "size" : "40x40",
      "scale" : "1x"
    },
    {
      "idiom" : "ipad",
      "size" : "40x40",
      "scale" : "2x"
    },
    {
      "idiom" : "ipad",
      "size" : "76x76",
      "scale" : "1x"
    },
    {
      "idiom" : "ipad",
      "size" : "76x76",
      "scale" : "2x"
    },
    {
      "idiom" : "ipad",
      "size" : "83.5x83.5",
      "scale" : "2x"
    },
    {
      "idiom" : "ios-marketing",
      "size" : "1024x1024",
      "scale" : "1x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}

================================================
FILE: ios/VoskApiTest/Base.lproj/LaunchScreen.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="EHf-IW-A2E">
            <objects>
                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
                        <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="53" y="375"/>
        </scene>
    </scenes>
</document>


================================================
FILE: ios/VoskApiTest/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="bdW-KL-Y8Z">
    <device id="retina5_5" orientation="portrait">
        <adaptation id="fullscreen"/>
    </device>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="nEc-89-Iqu">
            <objects>
                <viewController id="bdW-KL-Y8Z" customClass="ViewController" customModule="VoskApiTest" customModuleProvider="target" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="Hyr-Dz-4mU"/>
                        <viewControllerLayoutGuide type="bottom" id="w4A-5X-uBu"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="m5v-US-bvR">
                        <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IaT-no-U3i" userLabel="Microphone">
                                <rect key="frame" x="124" y="34" width="157" height="30"/>
                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <state key="normal" title="Recognize Microphone"/>
                                <connections>
                                    <action selector="runRecognizeMicrohpone:" destination="bdW-KL-Y8Z" eventType="touchUpInside" id="hGB-lz-N2B"/>
                                </connections>
                            </button>
                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GC5-nT-FQR" userLabel="File">
                                <rect key="frame" x="90" y="84" width="221" height="41"/>
                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <state key="normal" title="Recognize File"/>
                                <connections>
                                    <action selector="runRecognizeFile:" destination="bdW-KL-Y8Z" eventType="touchUpInside" id="xp5-Yi-rnN"/>
                                </connections>
                            </button>
                            <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" text="Results here" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="w4X-cu-USq">
                                <rect key="frame" x="11" y="112" width="383" height="569"/>
                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
                            </textView>
                        </subviews>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                    </view>
                    <connections>
                        <outlet property="mainText" destination="w4X-cu-USq" id="rZS-nz-Wql"/>
                        <outlet property="recognizeFile" destination="GC5-nT-FQR" id="dRe-tc-IA0"/>
                        <outlet property="recognizeMicrophone" destination="IaT-no-U3i" id="IuM-aa-pAP"/>
                    </connections>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="nWA-4D-pA6" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="-17.39130434782609" y="-285.32608695652175"/>
        </scene>
    </scenes>
</document>


================================================
FILE: ios/VoskApiTest/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>$(PRODUCT_NAME)</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
</dict>
</plist>


================================================
FILE: ios/VoskApiTest/ViewController.swift
================================================
//
//  ViewController.swift
//  VoskApiTest
//
//  Created by Niсkolay Shmyrev on 01.03.20.
//  Copyright © 2020-2021 Alpha Cephei. All rights reserved.
//

import UIKit
import AVFoundation

enum WorkMode {
    case stopped
    case microphone
    case file
}

class ViewController: UIViewController {
    
    var mode: WorkMode!
    
    @IBOutlet weak var recognizeFile: UIButton!
    @IBOutlet weak var mainText: UITextView!
    @IBOutlet weak var recognizeMicrophone: UIButton!
    
    var audioEngine : AVAudioEngine!
    var processingQueue: DispatchQueue!
    var model : VoskModel!
    
    func setMode(mode: WorkMode) {
        switch mode {
        case .stopped:
            self.recognizeFile.isEnabled = true
            self.recognizeMicrophone.isEnabled = true
            self.recognizeMicrophone.setTitle("Recognize Microphone",for: .normal)
        case .microphone:
            self.recognizeFile.isEnabled = false
            self.recognizeMicrophone.isEnabled = true
            self.recognizeMicrophone.setTitle("Stop Microphone",for: .normal)
            self.mainText.text = ""
        case .file:
            self.recognizeFile.isEnabled = false
            self.recognizeMicrophone.isEnabled = false
            self.mainText.text =  "Processing file..."
        }
        self.mode = mode
    }
    
    func startAudioEngine() {
        do {
            
            // Create a new audio engine.
            audioEngine = AVAudioEngine()
            
            let inputNode = audioEngine.inputNode
            let formatInput = inputNode.inputFormat(forBus: 0)
            let formatPcm = AVAudioFormat.init(commonFormat: AVAudioCommonFormat.pcmFormatInt16, sampleRate: formatInput.sampleRate, channels: 1, interleaved: true)
            
            let recognizer = Vosk(model: model, sampleRate: Float(formatInput.sampleRate))
            
            inputNode.installTap(onBus: 0,
                                 bufferSize: UInt32(formatInput.sampleRate / 10),
                                 format: formatPcm) { buffer, time in
                                    self.processingQueue.async {
                                        let res = recognizer.recognizeData(buffer: buffer)
                                        DispatchQueue.main.async {
                                            self.mainText.text = res + "\n" + self.mainText.text
                                        }
                                    }
            }
            
            // Start the stream of audio data.
            audioEngine.prepare()
            try audioEngine.start()
        } catch {
            print("Unable to start AVAudioEngine: \(error.localizedDescription)")
        }
    }
    
    func stopAudioEngine() {
        audioEngine.stop()
    }
    
    @IBAction func runRecognizeMicrohpone(_ sender: Any) {
        if (mode == .stopped) {
            setMode(mode: .microphone)
            startAudioEngine()
        } else {
            stopAudioEngine()
            setMode(mode: .stopped)
        }
    }
    
    @IBAction func runRecognizeFile(_ sender: Any) {
        setMode(mode: .file)
        processingQueue.async {
            let recognizer = Vosk(model: self.model, sampleRate: 16000.0)
            let res = recognizer.recognizeFile()
            DispatchQueue.main.async {
                self.mainText.text = res
                self.setMode(mode: .stopped)
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setMode(mode: .stopped)
        processingQueue = DispatchQueue(label: "recognizerQueue")
        model = VoskModel()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}



================================================
FILE: ios/VoskApiTest/Vosk/vosk_api.h
================================================
// Copyright 2020-2021 Alpha Cephei Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* This header contains the C API for Vosk speech recognition system */

#ifndef VOSK_API_H
#define VOSK_API_H

#ifdef __cplusplus
extern "C" {
#endif

/** Model stores all the data required for recognition
 *  it contains static data and can be shared across processing
 *  threads. */
typedef struct VoskModel VoskModel;


/** Speaker model is the same as model but contains the data
 *  for speaker identification. */
typedef struct VoskSpkModel VoskSpkModel;


/** Recognizer object is the main object which processes data.
 *  Each recognizer usually runs in own thread and takes audio as input.
 *  Once audio is processed recognizer returns JSON object as a string
 *  which represent decoded information - words, confidences, times, n-best lists,
 *  speaker information and so on */
typedef struct VoskRecognizer VoskRecognizer;


/** Loads model data from the file and returns the model object
 *
 * @param model_path: the path of the model on the filesystem
 * @returns model object or NULL if problem occured */
VoskModel *vosk_model_new(const char *model_path);


/** Releases the model memory
 *
 *  The model object is reference-counted so if some recognizer
 *  depends on this model, model might still stay alive. When
 *  last recognizer is released, model will be released too. */
void vosk_model_free(VoskModel *model);


/** Check if a word can be recognized by the model
 * @param word: the word
 * @returns the word symbol if @param word exists inside the model
 * or -1 otherwise.
 * Reminding that word symbol 0 is for <epsilon> */
int vosk_model_find_word(VoskModel *model, const char *word);


/** Loads speaker model data from the file and returns the model object
 *
 * @param model_path: the path of the model on the filesystem
 * @returns model object or NULL if problem occured */
VoskSpkModel *vosk_spk_model_new(const char *model_path);


/** Releases the model memory
 *
 *  The model object is reference-counted so if some recognizer
 *  depends on this model, model might still stay alive. When
 *  last recognizer is released, model will be released too. */
void vosk_spk_model_free(VoskSpkModel *model);

/** Creates the recognizer object
 *
 *  The recognizers process the speech and return text using shared model data
 *  @param model       VoskModel containing static data for recognizer. Model can be
 *                     shared across recognizers, even running in different threads.
 *  @param sample_rate The sample rate of the audio you going to feed into the recognizer.
 *                     Make sure this rate matches the audio content, it is a common
 *                     issue causing accuracy problems.
 *  @returns recognizer object or NULL if problem occured */
VoskRecognizer *vosk_recognizer_new(VoskModel *model, float sample_rate);


/** Creates the recognizer object with speaker recognition
 *
 *  With the speaker recognition mode the recognizer not just recognize
 *  text but also return speaker vectors one can use for speaker identification
 *
 *  @param model       VoskModel containing static data for recognizer. Model can be
 *                     shared across recognizers, even running in different threads.
 *  @param sample_rate The sample rate of the audio you going to feed into the recognizer.
 *                     Make sure this rate matches the audio content, it is a common
 *                     issue causing accuracy problems.
 *  @param spk_model speaker model for speaker identification
 *  @returns recognizer object or NULL if problem occured */
VoskRecognizer *vosk_recognizer_new_spk(VoskModel *model, float sample_rate, VoskSpkModel *spk_model);


/** Creates the recognizer object with the phrase list
 *
 *  Sometimes when you want to improve recognition accuracy and when you don't need
 *  to recognize large vocabulary you can specify a list of phrases to recognize. This
 *  will improve recognizer speed and accuracy but might return [unk] if user said
 *  something different.
 *
 *  Only recognizers with lookahead models support this type of quick configuration.
 *  Precompiled HCLG graph models are not supported.
 *
 *  @param model       VoskModel containing static data for recognizer. Model can be
 *                     shared across recognizers, even running in different threads.
 *  @param sample_rate The sample rate of the audio you going to feed into the recognizer.
 *                     Make sure this rate matches the audio content, it is a common
 *                     issue causing accuracy problems.
 *  @param grammar The string with the list of phrases to recognize as JSON array of strings,
 *                 for example "["one two three four five", "[unk]"]".
 *
 *  @returns recognizer object or NULL if problem occured */
VoskRecognizer *vosk_recognizer_new_grm(VoskModel *model, float sample_rate, const char *grammar);


/** Adds speaker model to already initialized recognizer
 *
 * Can add speaker recognition model to already created recognizer. Helps to initialize
 * speaker recognition for grammar-based recognizer.
 *
 * @param spk_model Speaker recognition model */
void vosk_recognizer_set_spk_model(VoskRecognizer *recognizer, VoskSpkModel *spk_model);


/** Configures recognizer to output n-best results
 *
 * <pre>
 *   {
 *      "alternatives": [
 *          { "text": "one two three four five", "confidence": 0.97 },
 *          { "text": "one two three for five", "confidence": 0.03 },
 *      ]
 *   }
 * </pre>
 *
 * @param max_alternatives - maximum alternatives to return from recognition results
 */
void vosk_recognizer_set_max_alternatives(VoskRecognizer *recognizer, int max_alternatives);


/** Enables words with times in the output
 *
 * <pre>
 *   "result" : [{
 *       "conf" : 1.000000,
 *       "end" : 1.110000,
 *       "start" : 0.870000,
 *       "word" : "what"
 *     }, {
 *       "conf" : 1.000000,
 *       "end" : 1.530000,
 *       "start" : 1.110000,
 *       "word" : "zero"
 *     }, {
 *       "conf" : 1.000000,
 *       "end" : 1.950000,
 *       "start" : 1.530000,
 *       "word" : "zero"
 *     }, {
 *       "conf" : 1.000000,
 *       "end" : 2.340000,
 *       "start" : 1.950000,
 *       "word" : "zero"
 *     }, {
 *       "conf" : 1.000000,
 *       "end" : 2.610000,
 *       "start" : 2.340000,
 *       "word" : "one"
 *     }],
 * </pre>
 *
 * @param words - boolean value
 */
void vosk_recognizer_set_words(VoskRecognizer *recognizer, int words);


/** Accept voice data
 *
 *  accept and process new chunk of voice data
 *
 *  @param data - audio data in PCM 16-bit mono format
 *  @param length - length of the audio data
 *  @returns 1 if silence is occured and you can retrieve a new utterance with result method 
 *           0 if decoding continues
 *           -1 if exception occured */
int vosk_recognizer_accept_waveform(VoskRecognizer *recognizer, const char *data, int length);


/** Same as above but the version with the short data for language bindings where you have
 *  audio as array of shorts */
int vosk_recognizer_accept_waveform_s(VoskRecognizer *recognizer, const short *data, int length);


/** Same as above but the version with the float data for language bindings where you have
 *  audio as array of floats */
int vosk_recognizer_accept_waveform_f(VoskRecognizer *recognizer, const float *data, int length);


/** Returns speech recognition result
 *
 * @returns the result in JSON format which contains decoded line, decoded
 *          words, times in seconds and confidences. You can parse this result
 *          with any json parser
 *
 * <pre>
 *  {
 *    "text" : "what zero zero zero one"
 *  }
 * </pre>
 *
 * If alternatives enabled it returns result with alternatives, see also vosk_recognizer_set_alternatives().
 *
 * If word times enabled returns word time, see also vosk_recognizer_set_word_times().
 */
const char *vosk_recognizer_result(VoskRecognizer *recognizer);


/** Returns partial speech recognition
 *
 * @returns partial speech recognition text which is not yet finalized.
 *          result may change as recognizer process more data.
 *
 * <pre>
 * {
 *    "partial" : "cyril one eight zero"
 * }
 * </pre>
 */
const char *vosk_recognizer_partial_result(VoskRecognizer *recognizer);


/** Returns speech recognition result. Same as result, but doesn't wait for silence
 *  You usually call it in the end of the stream to get final bits of audio. It
 *  flushes the feature pipeline, so all remaining audio chunks got processed.
 *
 *  @returns speech result in JSON format.
 */
const char *vosk_recognizer_final_result(VoskRecognizer *recognizer);


/** Resets the recognizer
 *
 *  Resets current results so the recognition can continue from scratch */
void vosk_recognizer_reset(VoskRecognizer *recognizer);


/** Releases recognizer object
 *
 *  Underlying model is also unreferenced and if needed released */
void vosk_recognizer_free(VoskRecognizer *recognizer);

/** Set log level for Kaldi messages
 *
 *  @param log_level the level
 *     0 - default value to print info and error messages but no debug
 *     less than 0 - don't print info messages
 *     greather than 0 - more verbose mode
 */
void vosk_set_log_level(int log_level);

/**
 *  Init, automatically select a CUDA device and allow multithreading.
 *  Must be called once from the main thread.
 *  Has no effect if HAVE_CUDA flag is not set.
 */
void vosk_gpu_init();

/**
 *  Init CUDA device in a multi-threaded environment.
 *  Must be called for each thread.
 *  Has no effect if HAVE_CUDA flag is not set.
 */
void vosk_gpu_thread_init();

#ifdef __cplusplus
}
#endif

#endif /* VOSK_API_H */


================================================
FILE: ios/VoskApiTest/Vosk.swift
================================================
//
//  Vosk.swift
//  VoskApiTest
//
//  Created by Niсkolay Shmyrev on 01.03.20.
//  Copyright © 2020-2021 Alpha Cephei. All rights reserved.
//

import Foundation
import AVFoundation

public final class Vosk {
    
    var recognizer : OpaquePointer!

    init(model: VoskModel, sampleRate: Float) {
        recognizer = vosk_recognizer_new_spk(model.model, sampleRate, model.spkModel)
    }
    
    deinit {
        vosk_recognizer_free(recognizer);
    }
    
    func recognizeFile() -> String {
        var sres = ""
        
        if let resourcePath = Bundle.main.resourcePath {
            
            let audioFile = URL(fileURLWithPath: resourcePath + "/10001-90210-01803.wav")
    
            if let data = try? Data(contentsOf: audioFile) {
                    let _ = data.withUnsafeBytes {
                        vosk_recognizer_accept_waveform(recognizer, $0, Int32(data.count))
                    }
                    let res = vosk_recognizer_final_result(recognizer);
                    sres = String(validatingUTF8: res!)!;
                    print(sres);
            }
        }
        
        return sres
    }
    
    
    func recognizeData(buffer : AVAudioPCMBuffer) -> String {
        let dataLen = Int(buffer.frameLength * 2)
        let channels = UnsafeBufferPointer(start: buffer.int16ChannelData, count: 1)
        let endOfSpeech = channels[0].withMemoryRebound(to: Int8.self, capacity: dataLen) {
            vosk_recognizer_accept_waveform(recognizer, $0, Int32(dataLen))
        }
        let res = endOfSpeech == 1 ?vosk_recognizer_result(recognizer) :vosk_recognizer_partial_result(recognizer)
        return String(validatingUTF8: res!)!;
    }
}


================================================
FILE: ios/VoskApiTest/VoskModel.swift
================================================
//
//  Vosk.swift
//  VoskApiTest
//
//  Created by Niсkolay Shmyrev on 01.03.20.
//  Copyright © 2020-2021 Alpha Cephei. All rights reserved.
//

import Foundation

public final class VoskModel {
    
    var model : OpaquePointer!
    var spkModel : OpaquePointer!
    
    init() {
        
        // Set to -1 to disable logs
        vosk_set_log_level(0);
        
        if let resourcePath = Bundle.main.resourcePath {
            let modelPath = resourcePath + "/vosk-model-small-en-us-0.15"
            let spkModelPath = resourcePath + "/vosk-model-spk-0.4"
            
            model = vosk_model_new(modelPath)
            spkModel = vosk_spk_model_new(spkModelPath)
        }
    }
    
    deinit {
        vosk_model_free(model)
        vosk_spk_model_free(spkModel)
    }
    
}



================================================
FILE: ios/VoskApiTest/bridging.h
================================================
#import "Vosk/vosk_api.h"


================================================
FILE: ios/VoskApiTest.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		92375222240C550B00DD6076 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92375221240C550B00DD6076 /* AppDelegate.swift */; };
		92375224240C550B00DD6076 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92375223240C550B00DD6076 /* ViewController.swift */; };
		92375227240C550B00DD6076 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 92375225240C550B00DD6076 /* Main.storyboard */; };
		92375229240C550B00DD6076 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92375228240C550B00DD6076 /* Assets.xcassets */; };
		9237522C240C550B00DD6076 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9237522A240C550B00DD6076 /* LaunchScreen.storyboard */; };
		92375234240C558900DD6076 /* Vosk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92375233240C558900DD6076 /* Vosk.swift */; };
		92375244240C6DAF00DD6076 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 92375243240C6DAF00DD6076 /* Accelerate.framework */; };
		92375274240C6F1E00DD6076 /* 10001-90210-01803.wav in Resources */ = {isa = PBXBuildFile; fileRef = 92375256240C6E3D00DD6076 /* 10001-90210-01803.wav */; };
		925527A9273C492C00FFD9CC /* libvosk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 925527A8273C492C00FFD9CC /* libvosk.a */; };
		92833003273C466E00058B52 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 92833002273C466E00058B52 /* libc++.tbd */; };
		92BACED125BE125A00B5CC93 /* vosk-model-small-en-us-0.15 in Resources */ = {isa = PBXBuildFile; fileRef = 928CC50C25BE124400490481 /* vosk-model-small-en-us-0.15 */; };
		92D6B8D325BDFEAC007FF08D /* VoskModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92D6B8D225BDFEAC007FF08D /* VoskModel.swift */; };
		92D86BD6253F823F0040D53F /* vosk-model-spk-0.4 in Resources */ = {isa = PBXBuildFile; fileRef = 92D86BD4253F823F0040D53F /* vosk-model-spk-0.4 */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
		9237521E240C550B00DD6076 /* VoskApiTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VoskApiTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
		92375221240C550B00DD6076 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
		92375223240C550B00DD6076 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
		92375226240C550B00DD6076 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
		92375228240C550B00DD6076 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
		9237522B240C550B00DD6076 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
		9237522D240C550B00DD6076 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		92375233240C558900DD6076 /* Vosk.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vosk.swift; sourceTree = "<group>"; };
		92375243240C6DAF00DD6076 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
		92375256240C6E3D00DD6076 /* 10001-90210-01803.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "10001-90210-01803.wav"; sourceTree = "<group>"; };
		925527A8273C492C00FFD9CC /* libvosk.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libvosk.a; sourceTree = "<group>"; };
		92833002273C466E00058B52 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
		928CC50C25BE124400490481 /* vosk-model-small-en-us-0.15 */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "vosk-model-small-en-us-0.15"; path = "/Users/shmyrev/Documents/IOS/VoskApiTest/VoskApiTest/Vosk/vosk-model-small-en-us-0.15"; sourceTree = "<absolute>"; };
		92AA22AD244CDD1200DA464B /* vosk_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vosk_api.h; sourceTree = "<group>"; };
		92AA22AE244CDD5200DA464B /* bridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bridging.h; sourceTree = "<group>"; };
		92D6B8D225BDFEAC007FF08D /* VoskModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoskModel.swift; sourceTree = "<group>"; };
		92D86BD4253F823F0040D53F /* vosk-model-spk-0.4 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "vosk-model-spk-0.4"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
		9237521B240C550B00DD6076 /* Frameworks */ = {
			isa = PBXFrameworksBuildPhase;
			buildActionMask = 2147483647;
			files = (
				92833003273C466E00058B52 /* libc++.tbd in Frameworks */,
				92375244240C6DAF00DD6076 /* Accelerate.framework in Frameworks */,
				925527A9273C492C00FFD9CC /* libvosk.a in Frameworks */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
		92375215240C550A00DD6076 = {
			isa = PBXGroup;
			children = (
				92375239240C642000DD6076 /* Vosk */,
				92375220240C550B00DD6076 /* VoskApiTest */,
				9237521F240C550B00DD6076 /* Products */,
				92375242240C6DAF00DD6076 /* Frameworks */,
			);
			sourceTree = "<group>";
		};
		9237521F240C550B00DD6076 /* Products */ = {
			isa = PBXGroup;
			children = (
				9237521E240C550B00DD6076 /* VoskApiTest.app */,
			);
			name = Products;
			sourceTree = "<group>";
		};
		92375220240C550B00DD6076 /* VoskApiTest */ = {
			isa = PBXGroup;
			children = (
				92AA22AE244CDD5200DA464B /* bridging.h */,
				92375221240C550B00DD6076 /* AppDelegate.swift */,
				92375223240C550B00DD6076 /* ViewController.swift */,
				92375225240C550B00DD6076 /* Main.storyboard */,
				92375228240C550B00DD6076 /* Assets.xcassets */,
				9237522A240C550B00DD6076 /* LaunchScreen.storyboard */,
				9237522D240C550B00DD6076 /* Info.plist */,
				92375233240C558900DD6076 /* Vosk.swift */,
				92D6B8D225BDFEAC007FF08D /* VoskModel.swift */,
			);
			path = VoskApiTest;
			sourceTree = "<group>";
		};
		92375239240C642000DD6076 /* Vosk */ = {
			isa = PBXGroup;
			children = (
				92D86BD4253F823F0040D53F /* vosk-model-spk-0.4 */,
				928CC50C25BE124400490481 /* vosk-model-small-en-us-0.15 */,
				925527A8273C492C00FFD9CC /* libvosk.a */,
				92AA22AD244CDD1200DA464B /* vosk_api.h */,
				92375256240C6E3D00DD6076 /* 10001-90210-01803.wav */,
			);
			name = Vosk;
			path = VoskApiTest/Vosk;
			sourceTree = "<group>";
		};
		92375242240C6DAF00DD6076 /* Frameworks */ = {
			isa = PBXGroup;
			children = (
				92833002273C466E00058B52 /* libc++.tbd */,
				92375243240C6DAF00DD6076 /* Accelerate.framework */,
			);
			name = Frameworks;
			sourceTree = "<group>";
		};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
		9237521D240C550B00DD6076 /* VoskApiTest */ = {
			isa = PBXNativeTarget;
			buildConfigurationList = 92375230240C550B00DD6076 /* Build configuration list for PBXNativeTarget "VoskApiTest" */;
			buildPhases = (
				9237521A240C550B00DD6076 /* Sources */,
				9237521B240C550B00DD6076 /* Frameworks */,
				9237521C240C550B00DD6076 /* Resources */,
			);
			buildRules = (
			);
			dependencies = (
			);
			name = VoskApiTest;
			productName = VoskApiTest;
			productReference = 9237521E240C550B00DD6076 /* VoskApiTest.app */;
			productType = "com.apple.product-type.application";
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		92375216240C550A00DD6076 /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastSwiftUpdateCheck = 0830;
				LastUpgradeCheck = 0920;
				ORGANIZATIONNAME = "Alpha Cephei";
				TargetAttributes = {
					9237521D240C550B00DD6076 = {
						CreatedOnToolsVersion = 8.3.2;
						LastSwiftMigration = 0920;
						ProvisioningStyle = Manual;
					};
				};
			};
			buildConfigurationList = 92375219240C550A00DD6076 /* Build configuration list for PBXProject "VoskApiTest" */;
			compatibilityVersion = "Xcode 3.2";
			developmentRegion = English;
			hasScannedForEncodings = 0;
			knownRegions = (
				en,
				Base,
			);
			mainGroup = 92375215240C550A00DD6076;
			productRefGroup = 9237521F240C550B00DD6076 /* Products */;
			projectDirPath = "";
			projectRoot = "";
			targets = (
				9237521D240C550B00DD6076 /* VoskApiTest */,
			);
		};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
		9237521C240C550B00DD6076 /* Resources */ = {
			isa = PBXResourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				92BACED125BE125A00B5CC93 /* vosk-model-small-en-us-0.15 in Resources */,
				92375274240C6F1E00DD6076 /* 10001-90210-01803.wav in Resources */,
				9237522C240C550B00DD6076 /* LaunchScreen.storyboard in Resources */,
				92375229240C550B00DD6076 /* Assets.xcassets in Resources */,
				92D86BD6253F823F0040D53F /* vosk-model-spk-0.4 in Resources */,
				92375227240C550B00DD6076 /* Main.storyboard in Resources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
		9237521A240C550B00DD6076 /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				92375224240C550B00DD6076 /* ViewController.swift in Sources */,
				92375222240C550B00DD6076 /* AppDelegate.swift in Sources */,
				92D6B8D325BDFEAC007FF08D /* VoskModel.swift in Sources */,
				92375234240C558900DD6076 /* Vosk.swift in Sources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
		92375225240C550B00DD6076 /* Main.storyboard */ = {
			isa = PBXVariantGroup;
			children = (
				92375226240C550B00DD6076 /* Base */,
			);
			name = Main.storyboard;
			sourceTree = "<group>";
		};
		9237522A240C550B00DD6076 /* LaunchScreen.storyboard */ = {
			isa = PBXVariantGroup;
			children = (
				9237522B240C550B00DD6076 /* Base */,
			);
			name = LaunchScreen.storyboard;
			sourceTree = "<group>";
		};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
		9237522E240C550B00DD6076 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				CLANG_ANALYZER_NONNULL = YES;
				CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_ENABLE_MODULES = YES;
				CLANG_ENABLE_OBJC_ARC = YES;
				CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
				CLANG_WARN_BOOL_CONVERSION = YES;
				CLANG_WARN_COMMA = YES;
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INFINITE_RECURSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
				CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
				CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
				CLANG_WARN_STRICT_PROTOTYPES = YES;
				CLANG_WARN_SUSPICIOUS_MOVE = YES;
				CLANG_WARN_UNREACHABLE_CODE = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
				COPY_PHASE_STRIP = NO;
				DEBUG_INFORMATION_FORMAT = dwarf;
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				ENABLE_TESTABILITY = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_OPTIMIZATION_LEVEL = 0;
				GCC_PREPROCESSOR_DEFINITIONS = (
					"DEBUG=1",
					"$(inherited)",
				);
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				IPHONEOS_DEPLOYMENT_TARGET = 10.3;
				MTL_ENABLE_DEBUG_INFO = YES;
				ONLY_ACTIVE_ARCH = YES;
				SDKROOT = iphoneos;
				SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
				SWIFT_OBJC_BRIDGING_HEADER = bridging.h;
				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
				SWIFT_SWIFT3_OBJC_INFERENCE = Default;
				TARGETED_DEVICE_FAMILY = "1,2";
			};
			name = Debug;
		};
		9237522F240C550B00DD6076 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				CLANG_ANALYZER_NONNULL = YES;
				CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_ENABLE_MODULES = YES;
				CLANG_ENABLE_OBJC_ARC = YES;
				CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
				CLANG_WARN_BOOL_CONVERSION = YES;
				CLANG_WARN_COMMA = YES;
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INFINITE_RECURSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
				CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
				CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
				CLANG_WARN_STRICT_PROTOTYPES = YES;
				CLANG_WARN_SUSPICIOUS_MOVE = YES;
				CLANG_WARN_UNREACHABLE_CODE = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
				COPY_PHASE_STRIP = NO;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				ENABLE_NS_ASSERTIONS = NO;
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				IPHONEOS_DEPLOYMENT_TARGET = 10.3;
				MTL_ENABLE_DEBUG_INFO = NO;
				ONLY_ACTIVE_ARCH = YES;
				SDKROOT = iphoneos;
				SWIFT_OBJC_BRIDGING_HEADER = bridging.h;
				SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
				SWIFT_SWIFT3_OBJC_INFERENCE = Default;
				TARGETED_DEVICE_FAMILY = "1,2";
				VALIDATE_PRODUCT = YES;
			};
			name = Release;
		};
		92375231240C550B00DD6076 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				CLANG_ENABLE_MODULES = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
				CODE_SIGN_STYLE = Manual;
				DEVELOPMENT_TEAM = "";
				ENABLE_BITCODE = NO;
				INFOPLIST_FILE = VoskApiTest/Info.plist;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				LIBRARY_SEARCH_PATHS = (
					"$(inherited)",
					"$(PROJECT_DIR)/VoskApiTest/Vosk",
				);
				PRODUCT_BUNDLE_IDENTIFIER = com.alphacephei.VoskApiTest;
				PRODUCT_NAME = "$(TARGET_NAME)";
				PROVISIONING_PROFILE_SPECIFIER = "";
				SWIFT_INSTALL_OBJC_HEADER = YES;
				SWIFT_OBJC_BRIDGING_HEADER = VoskApiTest/bridging.h;
				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
				SWIFT_SWIFT3_OBJC_INFERENCE = Default;
				SWIFT_VERSION = 4.0;
				TARGETED_DEVICE_FAMILY = "1,2";
			};
			name = Debug;
		};
		92375232240C550B00DD6076 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				CLANG_ENABLE_MODULES = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
				CODE_SIGN_STYLE = Manual;
				DEVELOPMENT_TEAM = "";
				ENABLE_BITCODE = NO;
				INFOPLIST_FILE = VoskApiTest/Info.plist;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				LIBRARY_SEARCH_PATHS = (
					"$(inherited)",
					"$(PROJECT_DIR)/VoskApiTest/Vosk",
				);
				PRODUCT_BUNDLE_IDENTIFIER = com.alphacephei.VoskApiTest;
				PRODUCT_NAME = "$(TARGET_NAME)";
				PROVISIONING_PROFILE_SPECIFIER = "";
				SWIFT_INSTALL_OBJC_HEADER = YES;
				SWIFT_OBJC_BRIDGING_HEADER = VoskApiTest/bridging.h;
				SWIFT_SWIFT3_OBJC_INFERENCE = Default;
				SWIFT_VERSION = 4.0;
				TARGETED_DEVICE_FAMILY = "1,2";
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		92375219240C550A00DD6076 /* Build configuration list for PBXProject "VoskApiTest" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				9237522E240C550B00DD6076 /* Debug */,
				9237522F240C550B00DD6076 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
		92375230240C550B00DD6076 /* Build configuration list for PBXNativeTarget "VoskApiTest" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				92375231240C550B00DD6076 /* Debug */,
				92375232240C550B00DD6076 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
/* End XCConfigurationList section */
	};
	rootObject = 92375216240C550A00DD6076 /* Project object */;
}


================================================
FILE: ios/VoskApiTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
   version = "1.0">
   <FileRef
      location = "self:">
   </FileRef>
</Workspace>


================================================
FILE: java/README.md
================================================
Java bindings for Vosk API using jnr-ffi

See demo project for details, build it with Gradle.

Download model and unpack as "model" folder in the demo project.

Make sure you are using recent JDK and Gradle.


================================================
FILE: java/demo/build.gradle
================================================
plugins {
    id 'application'
}

application {
    mainClass = 'org.vosk.demo.DecoderDemo'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation group: 'com.alphacephei', name: 'vosk', version: '0.3.75'
}


================================================
FILE: java/demo/src/main/java/org/vosk/demo/DecoderDemo.java
================================================
package org.vosk.demo;

import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;

import org.vosk.LogLevel;
import org.vosk.Recognizer;
import org.vosk.LibVosk;
import org.vosk.Model;

public class DecoderDemo {

    public static void main(String[] argv) throws IOException, UnsupportedAudioFileException {
        LibVosk.setLogLevel(LogLevel.DEBUG);

        try (Model model = new Model("model");
                    InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream("../../python/example/test.wav")));
                    Recognizer recognizer = new Recognizer(model, 16000)) {

            int nbytes;
            byte[] b = new byte[4096];
            while ((nbytes = ais.read(b)) >= 0) {
                if (recognizer.acceptWaveForm(b, nbytes)) {
                    System.out.println(recognizer.getResult());
                } else {
                    System.out.println(recognizer.getPartialResult());
                }
            }

            System.out.println(recognizer.getFinalResult());
        }
    }
}


================================================
FILE: java/lib/build.gradle
================================================
buildscript {
  repositories {
    mavenCentral()
  }
}

plugins {
    id 'java-library'
    id 'maven-publish'
    id 'com.vanniktech.maven.publish' version '0.18.0'
}

repositories {
    mavenCentral()
}

archivesBaseName = 'vosk'
group = 'com.alphacephei'
version = '0.3.75'

mavenPublish {
    group = 'com.alphacephei'
    version = version
    sonatypeHost = 's01'
}

dependencies {
    api group: 'net.java.dev.jna', name: 'jna', version: '5.18.1'
    testImplementation 'junit:junit:4.13'
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifactId = 'vosk'
            from components.java
            pom {
                name = 'Vosk'
                description = 'Speech recognition library'
                url = 'http://www.alphacephei.com.com/vosk/'
                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id = 'alphacephei'
                        name = 'Alpha Cephei Inc'
                        email = 'contact@alphacephei.com'
                    }
                }
                scm {
                    connection = 'scm:git:git://github.com/alphacep/vosk-api.git'
                    url = 'https://github.com/alphacep/vosk-api/'
                }
            }
        }
    }
}

test {
    dependsOn cleanTest
    testLogging.showStandardStreams = true
}

java {
    withSourcesJar()
    withJavadocJar()
}


================================================
FILE: java/lib/src/main/java/org/vosk/LibVosk.java
================================================
package org.vosk;

import com.sun.jna.Native;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

public class LibVosk {

    private static void unpackDll(File targetDir, String lib) throws IOException {
        try (InputStream source = LibVosk.class.getResourceAsStream("/win32-x86-64/" + lib + ".dll")) {
            Files.copy(source, new File(targetDir, lib + ".dll").toPath(), StandardCopyOption.REPLACE_EXISTING);
        }
    }

    static {

        if (Platform.isWindows()) {
            // We have to unpack dependencies
            try {
                // To get a tmp folder we unpack small library and mark it for deletion
                File tmpFile = Native.extractFromResourcePath("/win32-x86-64/empty", LibVosk.class.getClassLoader());
                File tmpDir = tmpFile.getParentFile();
                new File(tmpDir, tmpFile.getName() + ".x").createNewFile();

                // Now unpack dependencies
                unpackDll(tmpDir, "libwinpthread-1");
                unpackDll(tmpDir, "libgcc_s_seh-1");
                unpackDll(tmpDir, "libstdc++-6");

            } catch (IOException e) {
                // Nothing for now, it will fail on next step
            } finally {
                Native.register(LibVosk.class, "libvosk");
            }
        } else {
            Native.register(LibVosk.class, "vosk");
        }
    }

    public static native void vosk_set_log_level(int level);

    public static native Pointer vosk_model_new(String path);

    public static native void vosk_model_free(Pointer model);

    public static native Pointer vosk_spk_model_new(String path);

    public static native void vosk_spk_model_free(Pointer model);

    public static native Pointer vosk_recognizer_new(Model model, float sample_rate);

    public static native Pointer vosk_recognizer_new_spk(Pointer model, float sample_rate, Pointer spk_model);

    public static native Pointer vosk_recognizer_new_grm(Pointer model, float sample_rate, String grammar);

    public static native void vosk_recognizer_set_max_alternatives(Pointer recognizer, int max_alternatives);

    public static native void vosk_recognizer_set_words(Pointer recognizer, boolean words);

    public static native void vosk_recognizer_set_partial_words(Pointer recognizer, boolean partial_words);

    public static native void vosk_recognizer_set_spk_model(Pointer recognizer, Pointer spk_model);

    public static native boolean vosk_recognizer_accept_waveform(Pointer recognizer, byte[] data, int len);

    public static native boolean vosk_recognizer_accept_waveform_s(Pointer recognizer, short[] data, int len);

    public static native boolean vosk_recognizer_accept_waveform_f(Pointer recognizer, float[] data, int len);

    public static native String vosk_recognizer_result(Pointer recognizer);

    public static native String vosk_recognizer_final_result(Pointer recognizer);

    public static native String vosk_recognizer_partial_result(Pointer recognizer);

    public static native void vosk_recognizer_set_grm(Pointer recognizer, String grammar);

    public static native void vosk_recognizer_reset(Pointer recognizer);

    public static native void vosk_recognizer_set_endpointer_mode(Pointer recognizer, int mode);

    public static native void vosk_recognizer_set_endpointer_delays(Pointer recognizer, float t_start_max, float t_end, float t_max);

    public static native void vosk_recognizer_free(Pointer recognizer);

    public static native Pointer vosk_text_processor_new(String verbalizer, String tagger);

    public static native void vosk_text_processor_free(Pointer processor);

    public static native String vosk_text_processor_itn(Pointer processor, String input);

    /**
     * Set log level for Kaldi messages.
     *
     *  @param loglevel the level
     *     0 - default value to print info and error messages but no debug
     *     less than 0 - don't print info messages
     *     greater than 0 - more verbose mode
     */
    public static void setLogLevel(LogLevel loglevel) {
        vosk_set_log_level(loglevel.getValue());
    }
}


================================================
FILE: java/lib/src/main/java/org/vosk/LogLevel.java
================================================
package org.vosk;

public enum LogLevel {
    WARNINGS(-1),  // Print warning and errors
    INFO(0),       // Print info, along with warning and error messages, but no debug
    DEBUG(1);      // Print debug info

    private final int value;

    LogLevel(int value) {
        this.value = value;
    }

    public int getValue() {
        return this.value;
    }
}


================================================
FILE: java/lib/src/main/java/org/vosk/Model.java
================================================
package org.vosk;

import java.io.IOException;
import com.sun.jna.PointerType;

public class Model extends PointerType implements AutoCloseable {
    public Model() {
    }

    public Model(String path) throws IOException {
        super(LibVosk.vosk_model_new(path));

        if (getPointer() == null) {
            throw new IOException("Failed to create a model");
        }
    }

    @Override
    public void close() {
        LibVosk.vosk_model_free(this.getPointer());
    }
}


================================================
FILE: java/lib/src/main/java/org/vosk/Recognizer.java
================================================
package org.vosk;

import com.sun.jna.PointerType;
import java.io.IOException;

public class Recognizer extends PointerType implements AutoCloseable {
    /**
     * Creates the recognizer object.
     *
     * The recognizers process the speech and return text using shared model data
     * @param model       VoskModel containing static data for recognizer. Model can be
     *                    shared across recognizers, even running in different threads.
     * @param sampleRate The sample rate of the audio you are going to feed into the recognizer.
     *                    Make sure this rate matches the audio content, it is a common
     *                    issue causing accuracy problems.
     * @throws IOException if the recognizer could not be created
     */
    public Recognizer(Model model, float sampleRate) throws IOException {
        super(LibVosk.vosk_recognizer_new(model, sampleRate));

        if (getPointer() == null) {
            throw new IOException("Failed to create a recognizer");
        }
    }

    /**
     * Creates the recognizer object with speaker recognition.
     *
     *  With the speaker recognition mode the recognizer not just recognize
     *  text but also return speaker vectors one can use for speaker identification
     *
     *  @param model       VoskModel containing static data for recognizer. Model can be
     *                     shared across recognizers, even running in different threads.
     *  @param sampleRate The sample rate of the audio you are going to feed into the recognizer.
     *                     Make sure this rate matches the audio content, it is a common
     *                     issue causing accuracy problems.
     *  @param spkModel speaker model for speaker identification
     *  @throws IOException if the recognizer could not be created
     */
    public Recognizer(Model model, float sampleRate, SpeakerModel spkModel) throws IOException {
        super(LibVosk.vosk_recognizer_new_spk(model.getPointer(), sampleRate, spkModel.getPointer()));

        if (getPointer() == null) {
            throw new IOException("Failed to create a recognizer");
        }
    }

    /**
     * Creates the recognizer object with the phrase list.
     *
     *  Sometimes when you want to improve recognition accuracy and when you don't need
     *  to recognize large vocabulary you can specify a list of phrases to recognize. This
     *  will improve recognizer speed and accuracy but might return [unk] if user said
     *  something different.
     *
     *  Only recognizers with lookahead models support this type of quick configuration.
     *  Precompiled HCLG graph models are not supported.
     *
     *  @param model       VoskModel containing static data for recognizer. Model can be
     *                     shared across recognizers, even running in different threads.
     *  @param sampleRate The sample rate of the audio you are going to feed into the recognizer.
     *                     Make sure this rate matches the audio content, it is a common
     *                     issue causing accuracy problems.
     *  @param grammar The string with the list of phrases to recognize as JSON array of strings,
     *                 for example "["one two three four five", "[unk]"]".
     *  @throws IOException if the recognizer could not be created
     */
    public Recognizer(Model model, float sampleRate, String grammar) throws IOException {
        super(LibVosk.vosk_recognizer_new_grm(model.getPointer(), sampleRate, grammar));

        if (getPointer() == null) {
            throw new IOException("Failed to create a recognizer");
        }
    }

    /**
     * Configures recognizer to output n-best results.
     *
     * <pre>
     *   {
     *      "alternatives": [
     *          { "text": "one two three four five", "confidence": 0.97 },
     *          { "text": "one two three for five", "confidence": 0.03 },
     *      ]
     *   }
     * </pre>
     *
     * @param maxAlternatives - maximum alternatives to return from recognition results
     */
    public void setMaxAlternatives(int maxAlternatives) {
        LibVosk.vosk_recognizer_set_max_alternatives(this.getPointer(), maxAlternatives);
    }

    /** Enables words with times in the output
     *
     * <pre>
     *   "result" : [{
     *       "conf" : 1.000000,
     *       "end" : 1.110000,
     *       "start" : 0.870000,
     *       "word" : "what"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 1.530000,
     *       "start" : 1.110000,
     *       "word" : "zero"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 1.950000,
     *       "start" : 1.530000,
     *       "word" : "zero"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 2.340000,
     *       "start" : 1.950000,
     *       "word" : "zero"
     *     }, {
     *       "conf" : 1.000000,
     *       "end" : 2.610000,
     *       "start" : 2.340000,
     *       "word" : "one"
     *     }],
     * </pre>
     *
     * @param words - boolean value
     */
    public void setWords(boolean words) {
        LibVosk.vosk_recognizer_set_words(this.getPointer(), words);
    }

    /**
     * Like above return words and confidences in partial results.
     *
     * @param partial_words - boolean value
     */
    public void setPartialWords(boolean partial_words) {
        LibVosk.vosk_recognizer_set_partial_words(this.getPointer(), partial_words);
    }

    /**
     * Adds speaker model to already initialized recognizer.
     *
     * Can add speaker recognition model to already created recognizer.
     * Helps to initialize speaker recognition for grammar-based recognizer.
     *
     * @param spkModel Speaker recognition model
     */
    public void setSpeakerModel(SpeakerModel spkModel) {
        LibVosk.vosk_recognizer_set_spk_model(this.getPointer(), spkModel.getPointer());
    }

    /**
     * Accept and process new chunk of voice data.
     *
     *  @param data - audio data in PCM 16-bit mono format
     *  @param len - length of the audio data
     *  @return 1 if silence is occurred and you can retrieve a new utterance with result method
     *           0 if decoding continues
     *           -1 if exception occurred
     */
    public boolean acceptWaveForm(byte[] data, int len) {
        return LibVosk.vosk_recognizer_accept_waveform(this.getPointer(), data, len);
    }

    public boolean acceptWaveForm(short[] data, int len) {
        return LibVosk.vosk_recognizer_accept_waveform_s(this.getPointer(), data, len);
    }

    public boolean acceptWaveForm(float[] data, int len) {
        return LibVosk.vosk_recognizer_accept_waveform_f(this.getPointer(), data, len);
    }

    /**
     * Returns speech recognition result
     *
     * @return the result in JSON format which contains decoded line, decoded
     *          words, times in seconds and confidences. You can parse this result
     *          with any json parser
     *
     * <pre>
     *  {
     *    "text" : "what zero zero zero one"
     *  }
     * </pre>
     *
     * If alternatives enabled it returns result with alternatives, see also #setMaxAlternatives().
     *
     * If word times enabled returns word time, see also #setWordTimes().
     */
    public String getResult() {
        return LibVosk.vosk_recognizer_result(this.getPointer());
    }

    /**
     * Returns partial speech recognition.
     *
     * @return partial speech recognition text which is not yet finalized.
     *          result may change as recognizer process more data.
     *
     * <pre>
     * {
     *    "partial" : "cyril one eight zero"
     * }
     * </pre>
     */
    public String getPartialResult() {
        return LibVosk.vosk_recognizer_partial_result(this.getPointer());
    }

    /**
     * Returns speech recognition result. Same as result, but doesn't wait for silence.
     *  You usually call it in the end of the stream to get final bits of audio. It
     *  flushes the feature pipeline, so all remaining audio chunks got processed.
     *
     *  @return speech result in JSON format.
     */
    public String getFinalResult() {
        return LibVosk.vosk_recognizer_final_result(this.getPointer());
    }

    /**
     * Reconfigures recognizer to use grammar.
     *
     * @param grammar      Set of phrases in JSON array of strings or "[]" to use default model graph.
     * @see #Recognizer(Model, float, String)
     */
    public void setGrammar(String grammar) {
        LibVosk.vosk_recognizer_set_grm(this.getPointer(), grammar);
    }

    /**
     * Resets the recognizer.
     * Resets current results so the recognition can continue from scratch.
     */
    public void reset() {
        LibVosk.vosk_recognizer_reset(this.getPointer());
    }

    /**
     * Endpointer delay mode
     */
    public class EndpointerMode {
        public static final int DEFAULT = 0;
        public static final int SHORT = 1;
        public static final int LONG = 2;
        public static final int VERY_LONG = 3;
    }

    /**
     * Configures endpointer mode for recognizer
     */
    public void setEndpointerMode(int mode) {
        LibVosk.vosk_recognizer_set_endpointer_mode(this.getPointer(), mode);
    }

    /**
     * Set endpointer delays
     *
     * @param t_start_max     timeout for stopping recognition in case of initial silence (usually around 5.0)
     * @param t_end           timeout for stopping recognition in milliseconds after we recognized something (usually around 0.5 - 1.0)
     * @param t_max           timeout for forcing utterance end in milliseconds (usually around 20-30)
     **/
    public void setEndpointerDelays(float t_start_max, float t_end, float t_max) {
        LibVosk.vosk_recognizer_set_endpointer_delays(this.getPointer(), t_start_max, t_end, t_max);
    }

    /**
     * Releases recognizer object.
     * Underlying model is also unreferenced and if needed, released.
     */
    @Override
    public void close() {
        LibVosk.vosk_recognizer_free(this.getPointer());
    }
}


================================================
FILE: java/lib/src/main/java/org/vosk/SpeakerModel.java
================================================
package org.vosk;

import com.sun.jna.PointerType;
import java.io.IOException;

/**
 * Helps to initialize speaker recognition for grammar-based recognizer.
 */
public class SpeakerModel extends PointerType implements AutoCloseable {
    public SpeakerModel() {
    }

    /**
     * Loads speaker model data from the file.
     *
     * The path must contain:
     * - a config file: mfcc.conf
     * - kaldi nnet: final.ext.raw
     * - mean.vec
     * - transform.mat
     *
     * @param path the path of the model on the filesystem
     * @throws IOException if the model could not be created
     *
     * @see <a href="http://kaldi-asr.org/doc/structkaldi_1_1MfccOptions.html">Kaldi MfccOptions</a>
     * @see <a href="http://kaldi-asr.org/doc/classkaldi_1_1nnet3_1_1Nnet.html">Kaldi Nnet</a>
     */
    public SpeakerModel(String path) throws IOException {
        super(LibVosk.vosk_spk_model_new(path));

        if (getPointer() == null) {
            throw new IOException("Failed to create a speaker model");
        }
    }

    @Override
    public void close() {
        LibVosk.vosk_spk_model_free(this.getPointer());
    }
}


================================================
FILE: java/lib/src/main/resources/darwin/.keep-me
================================================


================================================
FILE: java/lib/src/main/resources/linux-x86-64/.keep-me
================================================


================================================
FILE: java/lib/src/main/resources/win32-x86-64/.keep-me
================================================


================================================
FILE: java/lib/src/main/resources/win32-x86-64/empty
================================================
Mainly for work around JNA API


================================================
FILE: java/lib/src/test/java/org/vosk/test/DecoderTest.java
================================================
package org.vosk.test;

import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import org.junit.Test;
import org.junit.Assert;

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;

import org.vosk.LogLevel;
import org.vosk.Recognizer;
import org.vosk.Recognizer.EndpointerMode;
import org.vosk.LibVosk;
import org.vosk.Model;
import org.vosk.TextProcessor;

public class DecoderTest {

    @Test
    public void decoderTest() throws IOException, UnsupportedAudioFileException {
        LibVosk.setLogLevel(LogLevel.DEBUG);

        try (Model model = new Model("model");
            InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream("../../python/example/test.wav")));
            Recognizer recognizer = new Recognizer(model, 16000)) {

            recognizer.setMaxAlternatives(10);
            recognizer.setWords(true);
            recognizer.setPartialWords(true);

            int nbytes;
            byte[] b = new byte[4096];
            while ((nbytes = ais.read(b)) >= 0) {
                if (recognizer.acceptWaveForm(b, nbytes)) {
                    System.out.println(recognizer.getResult());
                } else {
                    System.out.println(recognizer.getPartialResult());
                }
            }

            System.out.println(recognizer.getFinalResult());
        }
        Assert.assertTrue(true);
    }

    @Test
    public void decoderTestShort() throws IOException, UnsupportedAudioFileException {
        LibVosk.setLogLevel(LogLevel.DEBUG);

        try (Model model = new Model("model");
            InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream("../../python/example/test.wav")));
            Recognizer recognizer = new Recognizer(model, 16000)) {

            int nbytes;
            byte[] b = new byte[4096];
            short[] s = new short[2048];
            while ((nbytes = ais.read(b)) >= 0) {
                ByteBuffer.wrap(b).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(s);
                if (recognizer.acceptWaveForm(s, nbytes / 2)) {
                    System.out.println(recognizer.getResult());
                } else {
                    System.out.println(recognizer.getPartialResult());
                }
            }

            System.out.println(recognizer.getFinalResult());
        }
        Assert.assertTrue(true);
    }

    @Test
    public void decoderTestGrammar() throws IOException, UnsupportedAudioFileException {
        LibVosk.setLogLevel(LogLevel.DEBUG);

        try (Model model = new Model("model");
            InputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream("../../python/example/test.wav")));
            Recognizer recognizer = new Recognizer(model, 16000, "[\"one two three four five six seven eight nine zero oh\"]")) {

            int nbytes;
            byte[] b = new byte[4096];
            while ((nbytes = ais.read(b)) >= 0) {
                if (recognizer.acceptWaveForm(b, nbytes)) {
                    System.out.println(recognizer.getResult());
                } else {
                    System.out.println(recognizer.getPartialResult());
                }
            }

            System.out.println(recognizer.getFinalResult());
        }
        Assert.assertTrue(true);
    }

    @Test
    public void decoderEndpointerDelays() throws IOException, UnsupportedAudioFileException {
        try (Model model = new Model("model");
            Recognizer recognizer = new Recognizer(model, 16000)) {
            recognizer.setEndpointerMode(EndpointerMode.VERY_LONG);
            recognizer.setEndpointerDelays(5.0f, 3.0f, 50.0f);
	}
        Assert.assertTrue(true);
    }

    @Test(expected = IOException.class)
    public void decoderTestException() throws IOException {
        Model model = new Model("model_missing");
    }

    @Test
    public void testItn() throws IOException {
        TextProcessor p = new TextProcessor("model/itn/en_itn_tagger.fst", "model/itn/en_itn_verbalizer.fst");
        System.out.println(p.itn("as easy as one two three"));
    }
}


================================================
FILE: kotlin/.gitignore
================================================
.gradle/
.idea/
build/

================================================
FILE: kotlin/AUTHORS
================================================
Doomsdayrs doomsdayrs@gmail.com

================================================
FILE: kotlin/MAINTENANCE.md
================================================
# Maintenance

To maintain this module, please ensure the following.
1. Kotlin version is kept up to date.
This will be found in the plugins block of the [build.gradle.kts](./build.gradle.kts).
Ensure both multiplatform and serialization have the same value.
2. Ensure dependencies are up to date
3. Ensure that the android min & target sdks are up to date.

================================================
FILE: kotlin/README.md
================================================
# vosk-api-kotlin

The vosk-api wrapped using Kotlin Multiplatform.

## Usage

The following are ways to use this wrapper.

### JVM

For Java & Android targets.

```kotlin
dependencoes {
    val voskVersion = "0.4.0-alpha0"

    // Generic
    implementation("com.alphacephei:vosk-api-kotlin:$voskVersion")

    // Android
    implementation("com.alphacephei:vosk-api-kotlin-android:$voskVersion")
}
```

## Building

To build this project, follow the following steps.

1. Install `libvosk`.
This can be done from [source][source install] (parent monorepo) 
or [downloaded][download].
2. Download a [Vosk model](https://alphacephei.com/vosk/models) to use.
  - It is suggested to use a small model to speed up tests.
3. Once both are downloaded and placed into a proper location (hopefully following UNIX specification).
Set the following environment variables:
  - `VOSK_MODEL` to the path of the model.
  - `VOSK_PATH` to the path of `libvosk`.
These are used by the various tests to operate.
4. Now that the required steps are complete, one can run `./gradlew build`.

## Kotlin/Native

Currently, the native target is disabled due to a lack of vosk-api packaging on platforms.
Further worsened by the fact that installing the vosk-api on Linux systems is a chore.

First, either install from [source][source install]
or [download][download] and install into the proper unix directories as expected in
[libvosk.def](./src/nativeInterop/cinterop/libvosk.def).

To enable development for Kotlin/Native, do either for the following.
- Add `NATIVE_EXPERIMENT=true` to your environment.
- Go into [build.gradle.kts](./build.gradle.kts) & find `enableNative` & set the right side to true.

Afterwards, when syncing the project, the native source sets will become available to work on.
It is suggested to run `cinteropLibvoskNative` to generate the Kotlin C bindings to work with.

## Future

- Possibly target Kotlin/JS
- Possibly target Kotlin/Objective-C (?)

[source install]: https://alphacephei.com/vosk/install
[download]: https://github.com/alphacep/vosk-api/releases/latest

================================================
FILE: kotlin/build.gradle.kts
================================================
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

/*
 * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

plugins {
	kotlin("multiplatform") version "2.0.0"
	id("com.android.library")
	`maven-publish`
	id("org.jetbrains.dokka") version "1.9.20"
	kotlin("plugin.serialization") version "2.0.0"
}

group = "com.alphacephei"
version = "0.3.75"

repositories {
	google()
	mavenCentral()
}

val dokkaOutputDir = "$buildDir/dokka"

tasks.getByName<DokkaTask>("dokkaHtml") {
	outputDirectory.set(file(dokkaOutputDir))
}

val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
	delete(dokkaOutputDir)
}

val javadocJar = tasks.register<Jar>("javadocJar") {
	dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
	archiveClassifier.set("javadoc")
	from(dokkaOutputDir)
}

fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.native(
	configure: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests.() -> Unit = {}
) {
	when {
		org.jetbrains.kotlin.konan.target.HostManager.hostIsMingw -> mingwX64("native")
		org.jetbrains.kotlin.konan.target.HostManager.hostIsLinux -> linuxX64("native")
		org.jetbrains.kotlin.konan.target.HostManager.hostIsMac -> if (org.jetbrains.kotlin.konan.target.HostManager.hostArch() == "arm64") {
			macosArm64("native")
		} else {
			macosX64("native")
		}

		else -> error("Unsupported Host OS: ${org.jetbrains.kotlin.konan.target.HostManager.hostOs()}")
	}.apply(configure)
}

kotlin {
	jvm {
		@OptIn(ExperimentalKotlinGradlePluginApi::class)
		compilerOptions {
			jvmTarget.set(JvmTarget.JVM_17)
		}

		testRuns["test"].executionTask.configure {
			useJUnitPlatform()
			environment("MODEL", "VOSK_MODEL")
			//environment("MODEL", "/home/doomsdayrs/Downloads/vosk-model-small-en-us-0.15/")
			environment("LIBRARY", "VOSK_PATH")
			//environment("LIBRARY", "/usr/local/lib64/libvosk/libvosk.so")
			environment("AUDIO", "$projectDir/../python/example/test.wav")
		}
	}

	androidTarget {
		publishAllLibraryVariants()
	}

	/**
	 * If native target should be enabled or not.
	 *
	 * Currently disabled as there is no proper packaging distribution currently.
	 */
	@Suppress("SimplifyBooleanWithConstants") // Ignore, the false is for overrides
	val enableNative = System.getenv("NATIVE_EXPERIMENT") == "true" || false

	if (enableNative)
		native {
			val main by compilations.getting
			val libvosk by main.cinterops.creating

			binaries {
				sharedLib()
			}
		}


	@OptIn(ExperimentalKotlinGradlePluginApi::class)
	applyDefaultHierarchyTemplate {
		withJvm()
		withAndroidTarget()

		if (enableNative)
			withNative()
	}

	publishing {
		publications {
			withType<MavenPublication> {
				artifact(javadocJar)
				pom {
					url.set("http://www.alphacephei.com.com/vosk/")
					licenses {
						license {
							name.set("The Apache License, Version 2.0")
							url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
						}
					}
					developers {
						developer {
							id.set("com.alphacephei")
							name.set("Alpha Cephei Inc")
							email.set("contact@alphacephei.com")
						}
					}
					scm {
						connection.set("scm:git:git://github.com/alphacep/vosk-api.git")
						url.set("https://github.com/alphacep/vosk-api/")
					}
				}
			}
		}
	}

	val jna_version = "5.14.0"
	val coroutines_version = "1.7.3"

	sourceSets {
		val commonMain by getting {
			dependencies {
				api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0")
				api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
			}
		}
		val commonTest by getting {
			dependencies {
				implementation(kotlin("test"))
				implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version")
			}
		}
		val jvmMain by getting {
			dependencies {
				api("net.java.dev.jna:jna:$jna_version")
			}
		}
		val jvmTest by getting
		if (enableNative) {
			val nativeMain by getting
		}
		val androidMain by getting {
			dependsOn(jvmMain)
			dependencies {
				api("net.java.dev.jna:jna:$jna_version@aar")
			}
		}
		val androidUnitTest by getting {
			dependencies {
				implementation("junit:junit:4.13.2")
			}
		}
	}
}

android {
	namespace = "com.alphacephei.library"
	compileSdk = 34
	sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
	defaultConfig {
		minSdk = 24
		targetSdk = 34
	}
	compileOptions {
		sourceCompatibility = JavaVersion.VERSION_17
		targetCompatibility = JavaVersion.VERSION_17
	}
	publishing {
		multipleVariants {
			withSourcesJar()
			withJavadocJar()
			allVariants()
		}
	}
}


================================================
FILE: kotlin/settings.gradle.kts
================================================
/*
 * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

pluginManagement {
	repositories {
		google()
		gradlePluginPortal()
		mavenCentral()
	}
	resolutionStrategy {
		eachPlugin {
			if (requested.id.namespace == "com.android") {
				useModule("com.android.tools.build:gradle:8.3.0")
			}
		}
	}
}
rootProject.name = "vosk-api-kotlin"

================================================
FILE: kotlin/src/androidMain/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.alphacephei.library">

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
</manifest>

================================================
FILE: kotlin/src/androidMain/kotlin/org/vosk/android/RecognitionListener.kt
================================================
/*
 * Copyright 2023 Alpha Cephei Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed 
Download .txt
gitextract_hf0bzx57/

├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── COPYING
├── README.md
├── android/
│   ├── README.md
│   ├── build.gradle
│   ├── lib/
│   │   ├── build-vosk.sh
│   │   ├── build.gradle
│   │   └── src/
│   │       └── main/
│   │           ├── AndroidManifest.xml
│   │           ├── java/
│   │           │   └── org/
│   │           │       └── vosk/
│   │           │           ├── LibVosk.java
│   │           │           ├── LogLevel.java
│   │           │           ├── Model.java
│   │           │           ├── Recognizer.java
│   │           │           ├── SpeakerModel.java
│   │           │           ├── TextProcessor.java
│   │           │           └── android/
│   │           │               ├── RecognitionListener.java
│   │           │               ├── SpeechService.java
│   │           │               ├── SpeechStreamService.java
│   │           │               └── StorageService.java
│   │           └── jniLibs/
│   │               ├── arm64-v8a/
│   │               │   └── .keep-me
│   │               ├── armeabi-v7a/
│   │               │   └── .keep-me
│   │               ├── x86/
│   │               │   └── .keep-me
│   │               └── x86_64/
│   │                   └── .keep-me
│   ├── model-en/
│   │   ├── build.gradle
│   │   └── src/
│   │       └── main/
│   │           └── AndroidManifest.xml
│   └── settings.gradle
├── c/
│   ├── Makefile
│   ├── test_vosk.c
│   └── test_vosk_speaker.c
├── csharp/
│   ├── README.md
│   ├── demo/
│   │   ├── VoskDemo.cs
│   │   └── VoskDemo.csproj
│   └── nuget/
│       ├── Vosk.csproj
│       ├── Vosk.nuspec
│       ├── build/
│       │   ├── Vosk.targets
│       │   └── lib/
│       │       ├── linux-x64/
│       │       │   └── .keep-me
│       │       ├── osx-universal/
│       │       │   └── .keep-me
│       │       └── win-x64/
│       │           └── .keep-me
│       ├── build.sh
│       └── src/
│           ├── BatchModel.cs
│           ├── Model.cs
│           ├── SpkModel.cs
│           ├── Vosk.cs
│           ├── VoskBatchRecognizer.cs
│           ├── VoskPINVOKE.cs
│           └── VoskRecognizer.cs
├── go/
│   ├── COPYING
│   ├── README.md
│   ├── batch.go
│   ├── batch_example/
│   │   ├── README.md
│   │   └── test_batch.go
│   ├── doc.go
│   ├── example/
│   │   ├── README.md
│   │   ├── doc.go
│   │   └── test_simple.go
│   ├── go.mod
│   └── vosk.go
├── ios/
│   ├── README
│   ├── VoskApiTest/
│   │   ├── AppDelegate.swift
│   │   ├── Assets.xcassets/
│   │   │   └── AppIcon.appiconset/
│   │   │       └── Contents.json
│   │   ├── Base.lproj/
│   │   │   ├── LaunchScreen.storyboard
│   │   │   └── Main.storyboard
│   │   ├── Info.plist
│   │   ├── ViewController.swift
│   │   ├── Vosk/
│   │   │   └── vosk_api.h
│   │   ├── Vosk.swift
│   │   ├── VoskModel.swift
│   │   └── bridging.h
│   └── VoskApiTest.xcodeproj/
│       ├── project.pbxproj
│       └── project.xcworkspace/
│           └── contents.xcworkspacedata
├── java/
│   ├── README.md
│   ├── demo/
│   │   ├── build.gradle
│   │   └── src/
│   │       └── main/
│   │           └── java/
│   │               └── org/
│   │                   └── vosk/
│   │                       └── demo/
│   │                           └── DecoderDemo.java
│   └── lib/
│       ├── build.gradle
│       └── src/
│           ├── main/
│           │   ├── java/
│           │   │   └── org/
│           │   │       └── vosk/
│           │   │           ├── LibVosk.java
│           │   │           ├── LogLevel.java
│           │   │           ├── Model.java
│           │   │           ├── Recognizer.java
│           │   │           └── SpeakerModel.java
│           │   └── resources/
│           │       ├── darwin/
│           │       │   └── .keep-me
│           │       ├── linux-x86-64/
│           │       │   └── .keep-me
│           │       └── win32-x86-64/
│           │           ├── .keep-me
│           │           └── empty
│           └── test/
│               └── java/
│                   └── org/
│                       └── vosk/
│                           └── test/
│                               └── DecoderTest.java
├── kotlin/
│   ├── .gitignore
│   ├── AUTHORS
│   ├── MAINTENANCE.md
│   ├── README.md
│   ├── build.gradle.kts
│   ├── settings.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   ├── AndroidManifest.xml
│       │   └── kotlin/
│       │       └── org/
│       │           └── vosk/
│       │               └── android/
│       │                   ├── RecognitionListener.kt
│       │                   ├── SpeechService.kt
│       │                   ├── SpeechStreamService.kt
│       │                   └── StorageService.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── org/
│       │           └── vosk/
│       │               ├── AcceptWaveformException.kt
│       │               ├── BatchModel.kt
│       │               ├── BatchRecognizer.kt
│       │               ├── EndPointerMode.kt
│       │               ├── Freeable.kt
│       │               ├── LogLevel.kt
│       │               ├── Model.kt
│       │               ├── Recognizer.kt
│       │               ├── SpeakerModel.kt
│       │               ├── TextProcessor.kt
│       │               ├── Vosk.kt
│       │               ├── exception/
│       │               │   ├── IOException.kt
│       │               │   ├── ModelException.kt
│       │               │   └── RecognizerException.kt
│       │               └── json/
│       │                   ├── Alternative.kt
│       │                   ├── Extension.kt
│       │                   ├── PartialResultOutput.kt
│       │                   ├── Result.kt
│       │                   ├── ResultOutput.kt
│       │                   └── WaveformResult.kt
│       ├── jvmMain/
│       │   └── kotlin/
│       │       └── org/
│       │           └── vosk/
│       │               ├── BatchModel.kt
│       │               ├── BatchRecognizer.kt
│       │               ├── LibVosk.kt
│       │               ├── Model.kt
│       │               ├── Recognizer.kt
│       │               ├── SpeakerModel.kt
│       │               ├── TextProcessor.kt
│       │               ├── Vosk.kt
│       │               ├── WaveformExt.kt
│       │               └── exception/
│       │                   └── IOException.kt
│       ├── jvmTest/
│       │   └── kotlin/
│       │       └── DecoderTest.kt
│       ├── nativeInterop/
│       │   └── cinterop/
│       │       └── libvosk.def
│       └── nativeMain/
│           └── kotlin/
│               └── org/
│                   └── vosk/
│                       ├── BatchModel.kt
│                       ├── BatchRecognizer.kt
│                       ├── FreeableExt.kt
│                       ├── IOException.kt
│                       ├── Model.kt
│                       ├── Recognizer.kt
│                       ├── SpeakerModel.kt
│                       ├── Utils.kt
│                       └── Vosk.kt
├── nodejs/
│   ├── .npmignore
│   ├── README.md
│   ├── demo/
│   │   ├── test_ffmpeg.js
│   │   ├── test_microphone.js
│   │   ├── test_simple.js
│   │   ├── test_simple_async.js
│   │   ├── test_speaker.js
│   │   └── test_srt.js
│   ├── index.js
│   └── package.json
├── python/
│   ├── .pylintrc
│   ├── README.md
│   ├── example/
│   │   ├── colab/
│   │   │   ├── kaldi-build.ipynb
│   │   │   ├── vosk-adaptation.ipynb
│   │   │   ├── vosk-training.ipynb
│   │   │   └── vosk.ipynb
│   │   ├── test_alternatives.py
│   │   ├── test_empty.py
│   │   ├── test_ep.py
│   │   ├── test_ffmpeg.py
│   │   ├── test_gpu_batch.py
│   │   ├── test_gradio.py
│   │   ├── test_itn.py
│   │   ├── test_microphone.py
│   │   ├── test_nlsml.py
│   │   ├── test_reset.py
│   │   ├── test_simple.py
│   │   ├── test_speaker.py
│   │   ├── test_srt.py
│   │   ├── test_text.py
│   │   ├── test_webvtt.py
│   │   └── test_words.py
│   ├── setup.py
│   ├── test/
│   │   └── transcribe_scp.py
│   ├── vosk/
│   │   ├── __init__.py
│   │   └── transcriber/
│   │       ├── __init__.py
│   │       ├── cli.py
│   │       └── transcriber.py
│   └── vosk_builder.py
├── ruby/
│   ├── .gitignore
│   ├── .rspec
│   ├── .rubocop.yml
│   ├── Gemfile
│   ├── README.md
│   ├── Rakefile
│   ├── bin/
│   │   ├── console
│   │   └── setup
│   ├── example/
│   │   ├── test_simple.rb
│   │   ├── test_srt.rb
│   │   └── test_words.rb
│   ├── exe/
│   │   └── vosk-transcriber
│   ├── lib/
│   │   ├── vosk/
│   │   │   ├── ffi.rb
│   │   │   ├── progressbar.rb
│   │   │   └── version.rb
│   │   └── vosk.rb
│   ├── sig/
│   │   └── vosk.rbs
│   ├── spec/
│   │   ├── spec_helper.rb
│   │   ├── vosk/
│   │   │   └── model_spec.rb
│   │   └── vosk_spec.rb
│   └── vosk.gemspec
├── rust/
│   └── README.md
├── src/
│   ├── Makefile
│   ├── batch_model.cc
│   ├── batch_model.h
│   ├── batch_recognizer.cc
│   ├── batch_recognizer.h
│   ├── json.h
│   ├── language_model.cc
│   ├── language_model.h
│   ├── model.cc
│   ├── model.h
│   ├── postprocessor.cc
│   ├── postprocessor.h
│   ├── recognizer.cc
│   ├── recognizer.h
│   ├── spk_model.cc
│   ├── spk_model.h
│   ├── vosk_api.cc
│   └── vosk_api.h
├── training/
│   ├── README.md
│   ├── RESULTS
│   ├── RESULTS.txt
│   ├── cmd.sh
│   ├── conf/
│   │   ├── mfcc.conf
│   │   └── online_cmvn.conf
│   ├── local/
│   │   ├── chain/
│   │   │   ├── run_ivector_common.sh
│   │   │   └── run_tdnn.sh
│   │   ├── data_prep.sh
│   │   ├── download_and_untar.sh
│   │   ├── download_lm.sh
│   │   ├── prepare_dict.sh
│   │   └── score.sh
│   ├── path.sh
│   └── run.sh
├── travis/
│   ├── Dockerfile.dockcross
│   ├── Dockerfile.dockcross-manylinux
│   ├── Dockerfile.dockcross-musl
│   ├── Dockerfile.manylinux
│   ├── Dockerfile.manylinux-mkl
│   ├── Dockerfile.win
│   ├── Dockerfile.win32
│   ├── Dockerfile.winaarch64
│   ├── build-dockcross-manylinux.sh
│   ├── build-dockcross-musl.sh
│   ├── build-dockcross.sh
│   ├── build-docker-mkl.sh
│   ├── build-docker-win.sh
│   ├── build-docker-win32.sh
│   ├── build-docker-winaarch64.sh
│   ├── build-docker.sh
│   ├── build-wheels-dockcross.sh
│   ├── build-wheels-mkl.sh
│   ├── build-wheels-win.sh
│   ├── build-wheels-win32.sh
│   ├── build-wheels-winaarch64.sh
│   └── build-wheels.sh
└── webjs/
    ├── index.js
    └── package.json
Download .txt
SYMBOL INDEX (578 symbols across 60 files)

FILE: android/lib/src/main/java/org/vosk/LibVosk.java
  class LibVosk (line 13) | public class LibVosk {
    method vosk_set_log_level (line 19) | public static native void vosk_set_log_level(int level);
    method vosk_model_new (line 21) | public static native Pointer vosk_model_new(String path);
    method vosk_model_free (line 23) | public static native void vosk_model_free(Pointer model);
    method vosk_spk_model_new (line 25) | public static native Pointer vosk_spk_model_new(String path);
    method vosk_spk_model_free (line 27) | public static native void vosk_spk_model_free(Pointer model);
    method vosk_recognizer_new (line 29) | public static native Pointer vosk_recognizer_new(Model model, float sa...
    method vosk_recognizer_new_spk (line 31) | public static native Pointer vosk_recognizer_new_spk(Pointer model, fl...
    method vosk_recognizer_new_grm (line 33) | public static native Pointer vosk_recognizer_new_grm(Pointer model, fl...
    method vosk_recognizer_set_max_alternatives (line 35) | public static native void vosk_recognizer_set_max_alternatives(Pointer...
    method vosk_recognizer_set_words (line 37) | public static native void vosk_recognizer_set_words(Pointer recognizer...
    method vosk_recognizer_set_partial_words (line 39) | public static native void vosk_recognizer_set_partial_words(Pointer re...
    method vosk_recognizer_set_spk_model (line 41) | public static native void vosk_recognizer_set_spk_model(Pointer recogn...
    method vosk_recognizer_accept_waveform (line 43) | public static native boolean vosk_recognizer_accept_waveform(Pointer r...
    method vosk_recognizer_accept_waveform_s (line 45) | public static native boolean vosk_recognizer_accept_waveform_s(Pointer...
    method vosk_recognizer_accept_waveform_f (line 47) | public static native boolean vosk_recognizer_accept_waveform_f(Pointer...
    method vosk_recognizer_result (line 49) | public static native String vosk_recognizer_result(Pointer recognizer);
    method vosk_recognizer_final_result (line 51) | public static native String vosk_recognizer_final_result(Pointer recog...
    method vosk_recognizer_partial_result (line 53) | public static native String vosk_recognizer_partial_result(Pointer rec...
    method vosk_recognizer_set_grm (line 55) | public static native void vosk_recognizer_set_grm(Pointer recognizer, ...
    method vosk_recognizer_reset (line 57) | public static native void vosk_recognizer_reset(Pointer recognizer);
    method vosk_recognizer_set_endpointer_mode (line 59) | public static native void vosk_recognizer_set_endpointer_mode(Pointer ...
    method vosk_recognizer_set_endpointer_delays (line 61) | public static native void vosk_recognizer_set_endpointer_delays(Pointe...
    method vosk_recognizer_free (line 63) | public static native void vosk_recognizer_free(Pointer recognizer);
    method vosk_text_processor_new (line 65) | public static native Pointer vosk_text_processor_new(String verbalizer...
    method vosk_text_processor_free (line 67) | public static native void vosk_text_processor_free(Pointer processor);
    method vosk_text_processor_itn (line 69) | public static native String vosk_text_processor_itn(Pointer processor,...
    method setLogLevel (line 79) | public static void setLogLevel(LogLevel loglevel) {

FILE: android/lib/src/main/java/org/vosk/LogLevel.java
  type LogLevel (line 3) | public enum LogLevel {
    method LogLevel (line 10) | LogLevel(int value) {
    method getValue (line 14) | public int getValue() {

FILE: android/lib/src/main/java/org/vosk/Model.java
  class Model (line 6) | public class Model extends PointerType implements AutoCloseable {
    method Model (line 7) | public Model() {
    method Model (line 10) | public Model(String path) throws IOException {
    method close (line 18) | @Override

FILE: android/lib/src/main/java/org/vosk/Recognizer.java
  class Recognizer (line 6) | public class Recognizer extends PointerType implements AutoCloseable {
    method Recognizer (line 18) | public Recognizer(Model model, float sampleRate) throws IOException {
    method Recognizer (line 40) | public Recognizer(Model model, float sampleRate, SpeakerModel spkModel...
    method Recognizer (line 68) | public Recognizer(Model model, float sampleRate, String grammar) throw...
    method setMaxAlternatives (line 90) | public void setMaxAlternatives(int maxAlternatives) {
    method setWords (line 127) | public void setWords(boolean words) {
    method setPartialWords (line 136) | public void setPartialWords(boolean partial_words) {
    method setSpeakerModel (line 148) | public void setSpeakerModel(SpeakerModel spkModel) {
    method acceptWaveForm (line 161) | public boolean acceptWaveForm(byte[] data, int len) {
    method acceptWaveForm (line 165) | public boolean acceptWaveForm(short[] data, int len) {
    method acceptWaveForm (line 169) | public boolean acceptWaveForm(float[] data, int len) {
    method getResult (line 190) | public String getResult() {
    method getPartialResult (line 206) | public String getPartialResult() {
    method getFinalResult (line 217) | public String getFinalResult() {
    method setGrammar (line 227) | public void setGrammar(String grammar) {
    method reset (line 235) | public void reset() {
    class EndpointerMode (line 242) | public class EndpointerMode {
    method setEndpointerMode (line 252) | public void setEndpointerMode(int mode) {
    method setEndpointerDelays (line 263) | public void setEndpointerDelays(float t_start_max, float t_end, float ...
    method close (line 271) | @Override

FILE: android/lib/src/main/java/org/vosk/SpeakerModel.java
  class SpeakerModel (line 9) | public class SpeakerModel extends PointerType implements AutoCloseable {
    method SpeakerModel (line 10) | public SpeakerModel() {
    method SpeakerModel (line 28) | public SpeakerModel(String path) throws IOException {
    method close (line 36) | @Override

FILE: android/lib/src/main/java/org/vosk/TextProcessor.java
  class TextProcessor (line 5) | public class TextProcessor extends PointerType implements AutoCloseable {
    method TextProcessor (line 6) | public TextProcessor() {
    method TextProcessor (line 9) | public TextProcessor(String verbalizer, String tagger) {
    method close (line 13) | @Override
    method itn (line 18) | public String itn(String input) {

FILE: android/lib/src/main/java/org/vosk/android/RecognitionListener.java
  type RecognitionListener (line 20) | public interface RecognitionListener {
    method onPartialResult (line 25) | void onPartialResult(String hypothesis);
    method onResult (line 30) | void onResult(String hypothesis);
    method onFinalResult (line 35) | void onFinalResult(String hypothesis);
    method onError (line 40) | void onError(Exception exception);
    method onTimeout (line 45) | void onTimeout();

FILE: android/lib/src/main/java/org/vosk/android/SpeechService.java
  class SpeechService (line 32) | public class SpeechService {
    method SpeechService (line 51) | @SuppressLint("MissingPermission")
    method startListening (line 75) | public boolean startListening(RecognitionListener listener) {
    method startListening (line 92) | public boolean startListening(RecognitionListener listener, int timeou...
    method stopRecognizerThread (line 101) | private boolean stopRecognizerThread() {
    method stop (line 123) | public boolean stop() {
    method cancel (line 133) | public boolean cancel() {
    method shutdown (line 143) | public void shutdown() {
    method setPause (line 147) | public void setPause(boolean paused) {
    method reset (line 156) | public void reset() {
    class RecognizerThread (line 162) | private final class RecognizerThread extends Thread {
      method RecognizerThread (line 172) | public RecognizerThread(RecognitionListener listener, int timeout) {
      method RecognizerThread (line 181) | public RecognizerThread(RecognitionListener listener) {
      method setPause (line 191) | public void setPause(boolean paused) {
      method reset (line 198) | public void reset() {
      method run (line 202) | @Override

FILE: android/lib/src/main/java/org/vosk/android/SpeechStreamService.java
  class SpeechStreamService (line 30) | public class SpeechStreamService {
    method SpeechStreamService (line 45) | public SpeechStreamService(Recognizer recognizer, InputStream inputStr...
    method start (line 57) | public boolean start(RecognitionListener listener) {
    method start (line 74) | public boolean start(RecognitionListener listener, int timeout) {
    method stop (line 89) | public boolean stop() {
    class RecognizerThread (line 105) | private final class RecognizerThread extends Thread {
      method RecognizerThread (line 112) | public RecognizerThread(RecognitionListener listener, int timeout) {
      method RecognizerThread (line 121) | public RecognizerThread(RecognitionListener listener) {
      method run (line 125) | @Override

FILE: android/lib/src/main/java/org/vosk/android/StorageService.java
  class StorageService (line 42) | public class StorageService {
    type Callback (line 46) | public interface Callback<R> {
      method onComplete (line 47) | void onComplete(R result);
    method unpack (line 50) | public static void unpack(Context context, String sourcePath, final St...
    method sync (line 64) | public static String sync(Context context, String sourcePath, String t...
    method readLine (line 93) | private static String readLine(InputStream is) throws IOException {
    method deleteContents (line 97) | private static boolean deleteContents(File dir) {
    method copyAssets (line 113) | private static void copyAssets(AssetManager assetManager, String path,...
    method copyFile (line 135) | private static void copyFile(AssetManager assetManager, String fileNam...

FILE: c/test_vosk.c
  function main (line 4) | int main() {

FILE: c/test_vosk_speaker.c
  function main (line 4) | int main() {

FILE: csharp/demo/VoskDemo.cs
  class VoskDemo (line 5) | public class VoskDemo
    method DemoBytes (line 7) | public static void DemoBytes(Model model)
    method DemoFloats (line 27) | public static void DemoFloats(Model model)
    method DemoSpeaker (line 52) | public static void DemoSpeaker(Model model)
    method Main (line 73) | public static void Main()

FILE: csharp/nuget/src/BatchModel.cs
  class BatchModel (line 5) | public class BatchModel : global::System.IDisposable
    method BatchModel (line 9) | internal BatchModel(global::System.IntPtr cPtr)
    method getCPtr (line 14) | internal static global::System.Runtime.InteropServices.HandleRef getCP...
    method Dispose (line 24) | public void Dispose()
    method Dispose (line 30) | protected virtual void Dispose(bool disposing)
    method BatchModel (line 42) | public BatchModel(string model_path) : this(VoskPINVOKE.new_BatchModel...
    method WaitForCompletion (line 46) | public void WaitForCompletion()

FILE: csharp/nuget/src/Model.cs
  class Model (line 3) | public class Model : global::System.IDisposable {
    method Model (line 6) | internal Model(global::System.IntPtr cPtr) {
    method getCPtr (line 10) | internal static global::System.Runtime.InteropServices.HandleRef getCP...
    method Dispose (line 18) | public void Dispose() {
    method Dispose (line 23) | protected virtual void Dispose(bool disposing) {
    method Model (line 32) | public Model(string model_path) : this(VoskPINVOKE.new_Model(model_pat...
    method FindWord (line 35) | public int FindWord(string word) {

FILE: csharp/nuget/src/SpkModel.cs
  class SpkModel (line 3) | public class SpkModel : global::System.IDisposable {
    method SpkModel (line 6) | internal SpkModel(global::System.IntPtr cPtr) {
    method getCPtr (line 10) | internal static global::System.Runtime.InteropServices.HandleRef getCP...
    method Dispose (line 18) | public void Dispose() {
    method Dispose (line 23) | protected virtual void Dispose(bool disposing) {
    method SpkModel (line 32) | public SpkModel(string model_path) : this(VoskPINVOKE.new_SpkModel(mod...

FILE: csharp/nuget/src/Vosk.cs
  class Vosk (line 3) | public class Vosk {
    method SetLogLevel (line 4) | public static void SetLogLevel(int level) {
    method GpuInit (line 8) | public static void GpuInit() {
    method GpuThreadInit (line 12) | public static void GpuThreadInit() {

FILE: csharp/nuget/src/VoskBatchRecognizer.cs
  class VoskBatchRecognizer (line 5) | public class VoskBatchRecognizer : System.IDisposable
    method VoskBatchRecognizer (line 9) | internal VoskBatchRecognizer(System.IntPtr cPtr)
    method getCPtr (line 14) | internal static System.Runtime.InteropServices.HandleRef getCPtr(VoskB...
    method Dispose (line 24) | public void Dispose()
    method Dispose (line 30) | protected virtual void Dispose(bool disposing)
    method VoskBatchRecognizer (line 42) | public VoskBatchRecognizer(BatchModel model, float sample_rate) : this...
    method AcceptWaveform (line 46) | public bool AcceptWaveform(byte[] data, int len)
    method PtrToStringUTF8 (line 51) | private static string PtrToStringUTF8(System.IntPtr ptr)
    method FrontResult (line 61) | public string FrontResult()
    method Result (line 66) | public string Result()
    method GetNumPendingChunks (line 73) | public int GetNumPendingChunks()
    method FinishStream (line 78) | public void FinishStream()
    method SetNLSML (line 83) | public void SetNLSML(bool nlsml)

FILE: csharp/nuget/src/VoskPINVOKE.cs
  class VoskPINVOKE (line 3) | class VoskPINVOKE {
    method VoskPINVOKE (line 5) | static VoskPINVOKE() {
    method new_Model (line 8) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method delete_Model (line 11) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method Model_vosk_model_find_word (line 14) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method new_SpkModel (line 17) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method delete_SpkModel (line 20) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method new_VoskRecognizer (line 23) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method new_VoskRecognizerSpk (line 26) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method new_VoskRecognizerGrm (line 29) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method delete_VoskRecognizer (line 32) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_SetMaxAlternatives (line 35) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_SetWords (line 38) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_SetPartialWords (line 41) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_SetSpkModel (line 44) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_AcceptWaveform (line 47) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_AcceptWaveformShort (line 50) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_AcceptWaveformFloat (line 53) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_Result (line 56) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_PartialResult (line 59) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_FinalResult (line 62) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_Reset (line 65) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_SetEndpointerMode (line 68) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskRecognizer_SetEndpointerDelays (line 71) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method SetLogLevel (line 74) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method GpuInit (line 77) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method GpuThreadInit (line 80) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method new_BatchModel (line 83) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method delete_BatchModel (line 86) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method wait_BatchModel (line 89) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method new_VoskBatchRecognizer (line 92) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method delete_VoskBatchRecognizer (line 95) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskBatchRecognizer_AcceptWaveform (line 98) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskBatchRecognizer_SetNLSML (line 101) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskBatchRecognizer_FinishStream (line 104) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskBatchRecognizer_FrontResult (line 107) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskBatchRecognizer_Pop (line 110) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...
    method VoskBatchRecognizer_GetPendingChunks (line 113) | [global::System.Runtime.InteropServices.DllImport("libvosk", EntryPoin...

FILE: csharp/nuget/src/VoskRecognizer.cs
  type EndpointerMode (line 3) | public enum EndpointerMode {
  class VoskRecognizer (line 10) | public class VoskRecognizer : System.IDisposable {
    method VoskRecognizer (line 13) | internal VoskRecognizer(System.IntPtr cPtr) {
    method getCPtr (line 17) | internal static System.Runtime.InteropServices.HandleRef getCPtr(VoskR...
    method Dispose (line 25) | public void Dispose() {
    method Dispose (line 30) | protected virtual void Dispose(bool disposing) {
    method VoskRecognizer (line 39) | public VoskRecognizer(Model model, float sample_rate) : this(VoskPINVO...
    method VoskRecognizer (line 42) | public VoskRecognizer(Model model, float sample_rate, SpkModel spk_mod...
    method VoskRecognizer (line 45) | public VoskRecognizer(Model model, float sample_rate, string grammar) ...
    method SetMaxAlternatives (line 48) | public void SetMaxAlternatives(int max_alternatives) {
    method SetWords (line 52) | public void SetWords(bool words) {
    method SetPartialWords (line 56) | public void SetPartialWords(bool partial_words) {
    method SetSpkModel (line 60) | public void SetSpkModel(SpkModel spk_model) {
    method AcceptWaveform (line 64) | public bool AcceptWaveform(byte[] data, int len) {
    method AcceptWaveform (line 68) | public bool AcceptWaveform(short[] sdata, int len) {
    method AcceptWaveform (line 72) | public bool AcceptWaveform(float[] fdata, int len) {
    method PtrToStringUTF8 (line 76) | private static string PtrToStringUTF8(System.IntPtr ptr) {
    method Result (line 85) | public string Result() {
    method PartialResult (line 89) | public string PartialResult() {
    method FinalResult (line 93) | public string FinalResult() {
    method Reset (line 97) | public void Reset() {
    method SetEndpointerMode (line 101) | public void SetEndpointerMode(EndpointerMode mode) {
    method SetEndpointerDelays (line 105) | public void SetEndpointerDelays(float t_start_max, float t_end, float ...

FILE: go/batch.go
  type VoskBatchModel (line 12) | type VoskBatchModel struct
    method Free (line 25) | func (m *VoskBatchModel) Free() {
    method Wait (line 29) | func (m *VoskBatchModel) Wait() {
  function NewBatchModel (line 17) | func NewBatchModel(modelPath string) (*VoskBatchModel, error) {
  function freeBatchModel (line 33) | func freeBatchModel(model *VoskBatchModel) {
  type VoskBatchRecognizer (line 38) | type VoskBatchRecognizer struct
    method Free (line 46) | func (r *VoskBatchRecognizer) Free() {
    method AcceptWaveform (line 58) | func (r *VoskBatchRecognizer) AcceptWaveform(buffer []byte) {
    method SetNlsml (line 69) | func (r *VoskBatchRecognizer) SetNlsml(nlsml int) {
    method FinishStream (line 76) | func (r *VoskBatchRecognizer) FinishStream() {
    method FrontResult (line 83) | func (r *VoskBatchRecognizer) FrontResult() string {
    method Pop (line 90) | func (r *VoskBatchRecognizer) Pop() {
    method GetPendingChunks (line 96) | func (r *VoskBatchRecognizer) GetPendingChunks() int {
  function freeBatchRecognizer (line 42) | func freeBatchRecognizer(recognizer *VoskBatchRecognizer) {
  function NewBatchRecognizer (line 51) | func NewBatchRecognizer(model *VoskBatchModel, sampleRate float64) (*Vos...

FILE: go/batch_example/test_batch.go
  function main (line 13) | func main() {

FILE: go/example/test_simple.go
  function main (line 14) | func main() {

FILE: go/vosk.go
  type VoskModel (line 12) | type VoskModel struct
    method Free (line 25) | func (m *VoskModel) Free() {
    method FindWord (line 36) | func (m *VoskModel) FindWord(word string) int {
  function NewModel (line 17) | func NewModel(modelPath string) (*VoskModel, error) {
  function freeModel (line 29) | func freeModel(model *VoskModel) {
  type VoskSpkModel (line 44) | type VoskSpkModel struct
    method Free (line 61) | func(s *VoskSpkModel) Free() {
  function NewSpkModel (line 49) | func NewSpkModel(spkModelPath string) (*VoskSpkModel, error) {
  function freeSpkModel (line 57) | func freeSpkModel(model *VoskSpkModel) {
  type VoskRecognizer (line 66) | type VoskRecognizer struct
    method Free (line 74) | func (r *VoskRecognizer) Free() {
    method SetSpkModel (line 102) | func (r *VoskRecognizer) SetSpkModel(spkModel *VoskSpkModel) {
    method SetGrm (line 107) | func (r *VoskRecognizer) SetGrm(grammar string) {
    method SetMaxAlternatives (line 114) | func (r *VoskRecognizer) SetMaxAlternatives(maxAlternatives int) {
    method SetWords (line 119) | func (r *VoskRecognizer) SetWords(words int) {
    method SetPartialWords (line 124) | func (r *VoskRecognizer) SetPartialWords(words int) {
    method SetEndpointerDelays (line 134) | func (r *VoskRecognizer) SetEndpointerDelays(startMax, end, max float6...
    method AcceptWaveform (line 139) | func (r *VoskRecognizer) AcceptWaveform(buffer []byte) int {
    method Result (line 147) | func (r *VoskRecognizer) Result() string {
    method PartialResult (line 152) | func (r *VoskRecognizer) PartialResult() string {
    method FinalResult (line 158) | func (r *VoskRecognizer) FinalResult() string {
    method Reset (line 163) | func (r *VoskRecognizer) Reset() {
  function freeRecognizer (line 70) | func freeRecognizer(recognizer *VoskRecognizer) {
  function NewRecognizer (line 79) | func NewRecognizer(model *VoskModel, sampleRate float64) (*VoskRecognize...
  function NewRecognizerSpk (line 86) | func NewRecognizerSpk(model *VoskModel, sampleRate float64, spkModel *Vo...
  function NewRecognizerGrm (line 93) | func NewRecognizerGrm(model *VoskModel, sampleRate float64, grammar stri...
  function SetLogLevel (line 168) | func SetLogLevel(logLevel int) {
  function GPUInit (line 173) | func GPUInit() {
  function GPUThreadInit (line 178) | func GPUThreadInit() {

FILE: ios/VoskApiTest/Vosk/vosk_api.h
  type VoskModel (line 27) | typedef struct VoskModel VoskModel;
  type VoskSpkModel (line 32) | typedef struct VoskSpkModel VoskSpkModel;
  type VoskRecognizer (line 40) | typedef struct VoskRecognizer VoskRecognizer;

FILE: java/demo/src/main/java/org/vosk/demo/DecoderDemo.java
  class DecoderDemo (line 16) | public class DecoderDemo {
    method main (line 18) | public static void main(String[] argv) throws IOException, Unsupported...

FILE: java/lib/src/main/java/org/vosk/LibVosk.java
  class LibVosk (line 12) | public class LibVosk {
    method unpackDll (line 14) | private static void unpackDll(File targetDir, String lib) throws IOExc...
    method vosk_set_log_level (line 45) | public static native void vosk_set_log_level(int level);
    method vosk_model_new (line 47) | public static native Pointer vosk_model_new(String path);
    method vosk_model_free (line 49) | public static native void vosk_model_free(Pointer model);
    method vosk_spk_model_new (line 51) | public static native Pointer vosk_spk_model_new(String path);
    method vosk_spk_model_free (line 53) | public static native void vosk_spk_model_free(Pointer model);
    method vosk_recognizer_new (line 55) | public static native Pointer vosk_recognizer_new(Model model, float sa...
    method vosk_recognizer_new_spk (line 57) | public static native Pointer vosk_recognizer_new_spk(Pointer model, fl...
    method vosk_recognizer_new_grm (line 59) | public static native Pointer vosk_recognizer_new_grm(Pointer model, fl...
    method vosk_recognizer_set_max_alternatives (line 61) | public static native void vosk_recognizer_set_max_alternatives(Pointer...
    method vosk_recognizer_set_words (line 63) | public static native void vosk_recognizer_set_words(Pointer recognizer...
    method vosk_recognizer_set_partial_words (line 65) | public static native void vosk_recognizer_set_partial_words(Pointer re...
    method vosk_recognizer_set_spk_model (line 67) | public static native void vosk_recognizer_set_spk_model(Pointer recogn...
    method vosk_recognizer_accept_waveform (line 69) | public static native boolean vosk_recognizer_accept_waveform(Pointer r...
    method vosk_recognizer_accept_waveform_s (line 71) | public static native boolean vosk_recognizer_accept_waveform_s(Pointer...
    method vosk_recognizer_accept_waveform_f (line 73) | public static native boolean vosk_recognizer_accept_waveform_f(Pointer...
    method vosk_recognizer_result (line 75) | public static native String vosk_recognizer_result(Pointer recognizer);
    method vosk_recognizer_final_result (line 77) | public static native String vosk_recognizer_final_result(Pointer recog...
    method vosk_recognizer_partial_result (line 79) | public static native String vosk_recognizer_partial_result(Pointer rec...
    method vosk_recognizer_set_grm (line 81) | public static native void vosk_recognizer_set_grm(Pointer recognizer, ...
    method vosk_recognizer_reset (line 83) | public static native void vosk_recognizer_reset(Pointer recognizer);
    method vosk_recognizer_set_endpointer_mode (line 85) | public static native void vosk_recognizer_set_endpointer_mode(Pointer ...
    method vosk_recognizer_set_endpointer_delays (line 87) | public static native void vosk_recognizer_set_endpointer_delays(Pointe...
    method vosk_recognizer_free (line 89) | public static native void vosk_recognizer_free(Pointer recognizer);
    method vosk_text_processor_new (line 91) | public static native Pointer vosk_text_processor_new(String verbalizer...
    method vosk_text_processor_free (line 93) | public static native void vosk_text_processor_free(Pointer processor);
    method vosk_text_processor_itn (line 95) | public static native String vosk_text_processor_itn(Pointer processor,...
    method setLogLevel (line 105) | public static void setLogLevel(LogLevel loglevel) {

FILE: java/lib/src/main/java/org/vosk/LogLevel.java
  type LogLevel (line 3) | public enum LogLevel {
    method LogLevel (line 10) | LogLevel(int value) {
    method getValue (line 14) | public int getValue() {

FILE: java/lib/src/main/java/org/vosk/Model.java
  class Model (line 6) | public class Model extends PointerType implements AutoCloseable {
    method Model (line 7) | public Model() {
    method Model (line 10) | public Model(String path) throws IOException {
    method close (line 18) | @Override

FILE: java/lib/src/main/java/org/vosk/Recognizer.java
  class Recognizer (line 6) | public class Recognizer extends PointerType implements AutoCloseable {
    method Recognizer (line 18) | public Recognizer(Model model, float sampleRate) throws IOException {
    method Recognizer (line 40) | public Recognizer(Model model, float sampleRate, SpeakerModel spkModel...
    method Recognizer (line 68) | public Recognizer(Model model, float sampleRate, String grammar) throw...
    method setMaxAlternatives (line 90) | public void setMaxAlternatives(int maxAlternatives) {
    method setWords (line 127) | public void setWords(boolean words) {
    method setPartialWords (line 136) | public void setPartialWords(boolean partial_words) {
    method setSpeakerModel (line 148) | public void setSpeakerModel(SpeakerModel spkModel) {
    method acceptWaveForm (line 161) | public boolean acceptWaveForm(byte[] data, int len) {
    method acceptWaveForm (line 165) | public boolean acceptWaveForm(short[] data, int len) {
    method acceptWaveForm (line 169) | public boolean acceptWaveForm(float[] data, int len) {
    method getResult (line 190) | public String getResult() {
    method getPartialResult (line 206) | public String getPartialResult() {
    method getFinalResult (line 217) | public String getFinalResult() {
    method setGrammar (line 227) | public void setGrammar(String grammar) {
    method reset (line 235) | public void reset() {
    class EndpointerMode (line 242) | public class EndpointerMode {
    method setEndpointerMode (line 252) | public void setEndpointerMode(int mode) {
    method setEndpointerDelays (line 263) | public void setEndpointerDelays(float t_start_max, float t_end, float ...
    method close (line 271) | @Override

FILE: java/lib/src/main/java/org/vosk/SpeakerModel.java
  class SpeakerModel (line 9) | public class SpeakerModel extends PointerType implements AutoCloseable {
    method SpeakerModel (line 10) | public SpeakerModel() {
    method SpeakerModel (line 28) | public SpeakerModel(String path) throws IOException {
    method close (line 36) | @Override

FILE: java/lib/src/test/java/org/vosk/test/DecoderTest.java
  class DecoderTest (line 23) | public class DecoderTest {
    method decoderTest (line 25) | @Test
    method decoderTestShort (line 52) | @Test
    method decoderTestGrammar (line 77) | @Test
    method decoderEndpointerDelays (line 100) | @Test
    method decoderTestException (line 110) | @Test(expected = IOException.class)
    method testItn (line 115) | @Test

FILE: nodejs/index.js
  function setLogLevel (line 111) | function setLogLevel(level) {
  class Model (line 119) | class Model {
    method constructor (line 126) | constructor(modelPath) {
    method free (line 145) | free() {
  class SpeakerModel (line 155) | class SpeakerModel {
    method constructor (line 162) | constructor(modelPath) {
    method free (line 181) | free() {
  function hasOwnProperty (line 195) | function hasOwnProperty(obj, prop) {
  class Recognizer (line 216) | class Recognizer {
    method constructor (line 230) | constructor(param) {
    method free (line 259) | free() {
    method setMaxAlternatives (line 276) | setMaxAlternatives(max_alternatives) {
    method setWords (line 313) | setWords(words) {
    method setPartialWords (line 318) | setPartialWords(partial_words) {
    method setSpkModel (line 327) | setSpkModel(spk_model) {
    method acceptWaveform (line 339) | acceptWaveform(data) {
    method acceptWaveformAsync (line 351) | acceptWaveformAsync(data) {
    method resultString (line 400) | resultString() {
    method result (line 408) | result() {
    method partialResult (line 418) | partialResult() {
    method finalResult (line 429) | finalResult() {
    method reset (line 437) | reset() {

FILE: python/example/test_gradio.py
  function transcribe (line 10) | def transcribe(stream, new_chunk):

FILE: python/example/test_microphone.py
  function int_or_str (line 16) | def int_or_str(text):
  function callback (line 23) | def callback(indata, frames, time, status):

FILE: python/example/test_speaker.py
  function cosine_dist (line 53) | def cosine_dist(x, y):

FILE: python/example/test_webvtt.py
  function timestring (line 21) | def timestring(seconds):
  function transcribe (line 29) | def transcribe():

FILE: python/setup.py
  class bdist_wheel_tag_name (line 25) | class bdist_wheel_tag_name(bdist_wheel):
    method get_tag (line 26) | def get_tag(self):

FILE: python/test/transcribe_scp.py
  function recognize (line 12) | def recognize(line):
  function main (line 29) | def main():

FILE: python/vosk/__init__.py
  function open_dll (line 22) | def open_dll():
  function list_models (line 39) | def list_models():
  function list_languages (line 44) | def list_languages():
  class Model (line 50) | class Model:
    method __init__ (line 51) | def __init__(self, model_path=None, model_name=None, lang=None):
    method __del__ (line 60) | def __del__(self):
    method vosk_model_find_word (line 64) | def vosk_model_find_word(self, word):
    method get_model_path (line 67) | def get_model_path(self, model_name, lang):
    method get_model_by_name (line 74) | def get_model_by_name(self, model_name):
    method get_model_by_lang (line 91) | def get_model_by_lang(self, lang):
    method download_model (line 110) | def download_model(self, model_name):
    method download_progress_hook (line 124) | def download_progress_hook(self, t):
  class SpkModel (line 134) | class SpkModel:
    method __init__ (line 136) | def __init__(self, model_path):
    method __del__ (line 142) | def __del__(self):
  class EndpointerMode (line 145) | class EndpointerMode(enum.Enum):
  class KaldiRecognizer (line 151) | class KaldiRecognizer:
    method __init__ (line 153) | def __init__(self, *args):
    method __del__ (line 168) | def __del__(self):
    method SetMaxAlternatives (line 171) | def SetMaxAlternatives(self, max_alternatives):
    method SetWords (line 174) | def SetWords(self, enable_words):
    method SetPartialWords (line 177) | def SetPartialWords(self, enable_partial_words):
    method SetNLSML (line 180) | def SetNLSML(self, enable_nlsml):
    method SetEndpointerMode (line 183) | def SetEndpointerMode(self, mode):
    method SetEndpointerDelays (line 186) | def SetEndpointerDelays(self, t_start_max, t_end, t_max):
    method SetSpkModel (line 189) | def SetSpkModel(self, spk_model):
    method SetGrammar (line 192) | def SetGrammar(self, grammar):
    method AcceptWaveform (line 195) | def AcceptWaveform(self, data):
    method Result (line 201) | def Result(self):
    method PartialResult (line 204) | def PartialResult(self):
    method FinalResult (line 207) | def FinalResult(self):
    method Reset (line 210) | def Reset(self):
    method SrtResult (line 213) | def SrtResult(self, stream, words_per_line = 7):
  function SetLogLevel (line 240) | def SetLogLevel(level):
  function GpuInit (line 244) | def GpuInit():
  function GpuThreadInit (line 248) | def GpuThreadInit():
  class BatchModel (line 251) | class BatchModel:
    method __init__ (line 253) | def __init__(self, model_path, *args):
    method __del__ (line 259) | def __del__(self):
    method Wait (line 262) | def Wait(self):
  class BatchRecognizer (line 265) | class BatchRecognizer:
    method __init__ (line 267) | def __init__(self, *args):
    method __del__ (line 273) | def __del__(self):
    method AcceptWaveform (line 276) | def AcceptWaveform(self, data):
    method Result (line 279) | def Result(self):
    method FinishStream (line 285) | def FinishStream(self):
    method GetPendingChunks (line 288) | def GetPendingChunks(self):
  class Processor (line 291) | class Processor:
    method __init__ (line 293) | def __init__(self, *args):
    method __del__ (line 299) | def __del__(self):
    method process (line 302) | def process(self, text):

FILE: python/vosk/transcriber/cli.py
  function main (line 48) | def main():

FILE: python/vosk/transcriber/transcriber.py
  class Transcriber (line 18) | class Transcriber:
    method __init__ (line 20) | def __init__(self, args):
    method recognize_stream (line 25) | def recognize_stream(self, rec, stream):
    method recognize_stream_server (line 50) | async def recognize_stream_server(self, proc):
    method format_result (line 74) | def format_result(self, result, words_per_line=7):
    method resample_ffmpeg (line 114) | def resample_ffmpeg(self, infile):
    method resample_ffmpeg_async (line 120) | async def resample_ffmpeg_async(self, infile):
    method server_worker (line 125) | async def server_worker(self):
    method pool_worker (line 156) | def pool_worker(self, inputdata):
    method process_task_list_server (line 187) | async def process_task_list_server(self, task_list):
    method process_task_list_pool (line 193) | def process_task_list_pool(self, task_list):
    method process_task_list (line 197) | def process_task_list(self, task_list):

FILE: ruby/lib/vosk.rb
  type Vosk (line 13) | module Vosk
    class Error (line 14) | class Error < StandardError; end
    function models (line 26) | def self.models
    function languages (line 32) | def self.languages
    class Model (line 40) | class Model
      method initialize (line 43) | def initialize(model_path: nil, model_name: nil, lang: nil)
      method vosk_model_find_word (line 48) | def vosk_model_find_word(word)
      method get_model_path (line 54) | def get_model_path(model_name, lang)
      method get_model_by_name (line 62) | def get_model_by_name(model_name)
      method get_model_by_lang (line 82) | def get_model_by_lang(lang)
      method download_model (line 106) | def download_model(model_path)
      method download_file (line 145) | def download_file(url, dest, &callback)
    class SpkModel (line 160) | class SpkModel
      method initialize (line 163) | def initialize(model_path)
    class EndpointerMode (line 169) | class EndpointerMode
    class KaldiRecognizer (line 180) | class KaldiRecognizer
      method initialize (line 183) | def initialize(model, sample_rate, grammar_or_spk_model = nil)
      method max_alternatives= (line 196) | def max_alternatives=(max_alternatives)
      method words= (line 200) | def words=(enable_words)
      method partial_words= (line 204) | def partial_words=(enable_partial_words)
      method nlsml= (line 208) | def nlsml=(enable_nlsml)
      method endpointer_mode= (line 212) | def endpointer_mode=(mode)
      method set_endpointer_delays (line 216) | def set_endpointer_delays(t_start_max, t_end, t_max)
      method spk_model= (line 220) | def spk_model=(spk_model)
      method grammar= (line 224) | def grammar=(grammar)
      method accept_waveform (line 228) | def accept_waveform(data)
      method result (line 235) | def result
      method partial_result (line 239) | def partial_result
      method final_result (line 243) | def final_result
      method reset (line 247) | def reset
      method srt_result (line 251) | def srt_result(stream, words_per_line: 7)
      method create_srt (line 263) | def create_srt(results, words_per_line)
    class BatchModel (line 283) | class BatchModel
      method initialize (line 287) | def initialize(model_path)
      method wait (line 291) | def wait
    class BatchRecognizer (line 297) | class BatchRecognizer
      method initialize (line 299) | def initialize(batch_model, sample_rate)
      method accept_waveform (line 303) | def accept_waveform(data)
      method result (line 307) | def result
      method finish_stream (line 313) | def finish_stream
      method pending_chunks (line 317) | def pending_chunks
    class Processor (line 323) | class Processor
      method initialize (line 325) | def initialize(lang, type)
      method process (line 329) | def process(text)
    function log_level= (line 334) | def self.log_level=(level)
    function gpu_init (line 338) | def self.gpu_init
    function gpu_thread_init (line 342) | def self.gpu_thread_init

FILE: ruby/lib/vosk/ffi.rb
  type Vosk (line 5) | module Vosk
    type C (line 6) | module C # :nodoc: all
      class VoskModel (line 20) | class VoskModel < FFI::AutoPointer
        method from_native (line 21) | def self.from_native(ptr, _ctx)
        method release (line 27) | def self.release(ptr)
      class VoskSpkModel (line 32) | class VoskSpkModel < FFI::AutoPointer
        method from_native (line 33) | def self.from_native(ptr, _ctx)
        method release (line 39) | def self.release(ptr)
      class VoskRecognizer (line 54) | class VoskRecognizer < FFI::AutoPointer
        method from_native (line 55) | def self.from_native(ptr, _ctx)
        method release (line 61) | def self.release(ptr)
      class VoskBatchModel (line 66) | class VoskBatchModel < FFI::AutoPointer
        method from_native (line 67) | def self.from_native(ptr, _ctx)
        method release (line 73) | def self.release(ptr)
      class VoskBatchRecognizer (line 78) | class VoskBatchRecognizer < FFI::AutoPointer
        method from_native (line 79) | def self.from_native(ptr, _ctx)
        method release (line 85) | def self.release(ptr)
      class VoskTextProcessor (line 90) | class VoskTextProcessor < FFI::AutoPointer
        method from_native (line 91) | def self.from_native(ptr, _ctx)
        method release (line 97) | def self.release(ptr)
      class OwnedString (line 149) | class OwnedString
        method to_native (line 154) | def self.to_native(_value, _context)
        method from_native (line 158) | def self.from_native((str, ptr), _context)

FILE: ruby/lib/vosk/progressbar.rb
  function rate_of_change (line 14) | def rate_of_change(format_string = "%s")
  class ProgressBar (line 21) | class ProgressBar # :nodoc: all
    class Progress (line 23) | class Progress
      method progress_with_precision (line 24) | def progress_with_precision
      method total_with_unknown_indicator_with_precision (line 28) | def total_with_unknown_indicator_with_precision
    type Components (line 33) | module Components
      class Time (line 35) | class Time
        method elapsed_no_label (line 36) | def elapsed_no_label
        method estimated_no_label (line 41) | def estimated_no_label

FILE: ruby/lib/vosk/version.rb
  type Vosk (line 3) | module Vosk

FILE: src/batch_model.cc
  type stat (line 30) | struct stat

FILE: src/batch_model.h
  function class (line 43) | class BatchModel {

FILE: src/batch_recognizer.h
  function class (line 28) | class BatchRecognizer {

FILE: src/json.h
  function namespace (line 21) | namespace json {
  function JSON (line 204) | static JSON Make( Class type ) {
  function consume_ws (line 450) | void consume_ws( const string &str, size_t &offset ) {
  function JSON (line 454) | JSON parse_object( const string &str, size_t &offset ) {
  function JSON (line 490) | JSON parse_array( const string &str, size_t &offset ) {
  function JSON (line 519) | JSON parse_string( const string &str, size_t &offset ) {
  function JSON (line 557) | JSON parse_number( const string &str, size_t &offset ) {
  function JSON (line 607) | JSON parse_bool( const string &str, size_t &offset ) {
  function JSON (line 621) | JSON parse_null( const string &str, size_t &offset ) {
  function JSON (line 631) | JSON parse_next( const string &str, size_t &offset ) {

FILE: src/language_model.cc
  function int32 (line 63) | int32 LanguageModelEstimator::FindLmStateIndexForHistory(
  function int32 (line 72) | int32 LanguageModelEstimator::FindNonzeroLmStateIndexForHistory(
  function int32 (line 88) | int32 LanguageModelEstimator::FindOrCreateLmStateIndexForHistory(
  function int32 (line 127) | int32 LanguageModelEstimator::AssignFstStates() {
  function int32 (line 148) | int32 LanguageModelEstimator::FindInitialFstState() const {

FILE: src/language_model.h
  function class (line 50) | class LanguageModelEstimator {

FILE: src/model.cc
  type fst (line 33) | namespace fst {
  function KaldiLogHandler (line 42) | static void KaldiLogHandler(const LogMessageEnvelope &env, const char *m...
  function KaldiLogHandler (line 75) | static void KaldiLogHandler(const LogMessageEnvelope &env, const char *m...
  type stat (line 120) | struct stat
  type stat (line 221) | struct stat

FILE: src/model.h
  function class (line 41) | class Model {

FILE: src/postprocessor.h
  function class (line 28) | class Processor {

FILE: src/recognizer.cc
  function RunNnetComputation (line 422) | static void RunNnetComputation(const MatrixBase<BaseFloat> &features,
  function CopyLatticeForMbr (line 518) | static void CopyLatticeForMbr(CompactLattice &lat, CompactLattice *lat_out)
  function CompactLatticeToWordAlignmentWeight (line 580) | static bool CompactLatticeToWordAlignmentWeight(const CompactLattice &clat,

FILE: src/recognizer.h
  type RecognizerState (line 36) | enum RecognizerState {
  function class (line 43) | class Recognizer {

FILE: src/spk_model.h
  function class (line 27) | class SpkModel {

FILE: src/vosk_api.cc
  function VoskModel (line 31) | VoskModel *vosk_model_new(const char *model_path)
  function vosk_model_free (line 40) | void vosk_model_free(VoskModel *model)
  function vosk_model_find_word (line 48) | int vosk_model_find_word(VoskModel *model, const char *word)
  function VoskSpkModel (line 53) | VoskSpkModel *vosk_spk_model_new(const char *model_path)
  function vosk_spk_model_free (line 62) | void vosk_spk_model_free(VoskSpkModel *model)
  function VoskRecognizer (line 70) | VoskRecognizer *vosk_recognizer_new(VoskModel *model, float sample_rate)
  function VoskRecognizer (line 79) | VoskRecognizer *vosk_recognizer_new_spk(VoskModel *model, float sample_r...
  function VoskRecognizer (line 88) | VoskRecognizer *vosk_recognizer_new_grm(VoskModel *model, float sample_r...
  function vosk_recognizer_set_max_alternatives (line 97) | void vosk_recognizer_set_max_alternatives(VoskRecognizer *recognizer, in...
  function vosk_recognizer_set_words (line 102) | void vosk_recognizer_set_words(VoskRecognizer *recognizer, int words)
  function vosk_recognizer_set_partial_words (line 107) | void vosk_recognizer_set_partial_words(VoskRecognizer *recognizer, int p...
  function vosk_recognizer_set_nlsml (line 112) | void vosk_recognizer_set_nlsml(VoskRecognizer *recognizer, int nlsml)
  function vosk_recognizer_set_spk_model (line 117) | void vosk_recognizer_set_spk_model(VoskRecognizer *recognizer, VoskSpkMo...
  function vosk_recognizer_set_grm (line 125) | void vosk_recognizer_set_grm(VoskRecognizer *recognizer, char const *gra...
  function vosk_recognizer_set_endpointer_mode (line 133) | void vosk_recognizer_set_endpointer_mode(VoskRecognizer *recognizer, Vos...
  function vosk_recognizer_set_endpointer_delays (line 141) | void vosk_recognizer_set_endpointer_delays(VoskRecognizer *recognizer, f...
  function vosk_recognizer_accept_waveform (line 149) | int vosk_recognizer_accept_waveform(VoskRecognizer *recognizer, const ch...
  function vosk_recognizer_accept_waveform_s (line 158) | int vosk_recognizer_accept_waveform_s(VoskRecognizer *recognizer, const ...
  function vosk_recognizer_accept_waveform_f (line 167) | int vosk_recognizer_accept_waveform_f(VoskRecognizer *recognizer, const ...
  function vosk_recognizer_reset (line 191) | void vosk_recognizer_reset(VoskRecognizer *recognizer)
  function vosk_recognizer_free (line 196) | void vosk_recognizer_free(VoskRecognizer *recognizer)
  function vosk_set_log_level (line 201) | void vosk_set_log_level(int log_level)
  function vosk_gpu_init (line 206) | void vosk_gpu_init()
  function vosk_gpu_thread_init (line 216) | void vosk_gpu_thread_init()
  function VoskBatchModel (line 223) | VoskBatchModel *vosk_batch_model_new(const char *model_path)
  function vosk_batch_model_free (line 232) | void vosk_batch_model_free(VoskBatchModel *model)
  function vosk_batch_model_wait (line 239) | void vosk_batch_model_wait(VoskBatchModel *model)
  function VoskBatchRecognizer (line 246) | VoskBatchRecognizer *vosk_batch_recognizer_new(VoskBatchModel *model, fl...
  function vosk_batch_recognizer_free (line 255) | void vosk_batch_recognizer_free(VoskBatchRecognizer *recognizer)
  function vosk_batch_recognizer_accept_waveform (line 262) | void vosk_batch_recognizer_accept_waveform(VoskBatchRecognizer *recogniz...
  function vosk_batch_recognizer_set_nlsml (line 269) | void vosk_batch_recognizer_set_nlsml(VoskBatchRecognizer *recognizer, in...
  function vosk_batch_recognizer_finish_stream (line 276) | void vosk_batch_recognizer_finish_stream(VoskBatchRecognizer *recognizer)
  function vosk_batch_recognizer_pop (line 292) | void vosk_batch_recognizer_pop(VoskBatchRecognizer *recognizer)
  function vosk_batch_recognizer_get_pending_chunks (line 300) | int vosk_batch_recognizer_get_pending_chunks(VoskBatchRecognizer *recogn...
  function VoskTextProcessor (line 309) | VoskTextProcessor *vosk_text_processor_new(const char *tagger, const cha...
  function vosk_text_processor_free (line 318) | void vosk_text_processor_free(VoskTextProcessor *processor)

FILE: src/vosk_api.h
  type VoskModel (line 27) | typedef struct VoskModel VoskModel;
  type VoskSpkModel (line 32) | typedef struct VoskSpkModel VoskSpkModel;
  type VoskRecognizer (line 40) | typedef struct VoskRecognizer VoskRecognizer;
  type VoskTextProcessor (line 43) | typedef struct VoskTextProcessor VoskTextProcessor;
  type VoskBatchModel (line 48) | typedef struct VoskBatchModel VoskBatchModel;
  type VoskBatchRecognizer (line 53) | typedef struct VoskBatchRecognizer VoskBatchRecognizer;
  type VoskEndpointerMode (line 222) | typedef enum VoskEpMode {
Condensed preview — 255 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4,261K chars).
[
  {
    "path": ".gitignore",
    "chars": 866,
    "preview": "# Object files\n*.o\n\n# Temp files\nnohup.out\n\n# Gradle files\n.gradle/\ngradlew\ngradlew.bat\ngradle\nlocal.properties\ngradle.p"
  },
  {
    "path": ".travis.yml",
    "chars": 311,
    "preview": "notifications:\n  email: false\n\nmatrix:\n  include:\n    - sudo: required\n      services:\n        - docker\n      env: DOCKE"
  },
  {
    "path": "CMakeLists.txt",
    "chars": 520,
    "preview": "cmake_minimum_required(VERSION 3.13)\nproject(vosk-api CXX)\n\nset(CMAKE_CXX_STANDARD 17)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\nad"
  },
  {
    "path": "COPYING",
    "chars": 10173,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 1107,
    "preview": "# Vosk Speech Recognition Toolkit\n\nVosk is an offline open source speech recognition toolkit. It enables\nspeech recognit"
  },
  {
    "path": "android/README.md",
    "chars": 79,
    "preview": "Vosk library for Android\n\nSee for details https://alphacephei.com/vosk/android\n"
  },
  {
    "path": "android/build.gradle",
    "chars": 1265,
    "preview": "buildscript {\n    repositories {\n        google()\n        mavenCentral()\n    }\n    dependencies {\n        classpath 'com"
  },
  {
    "path": "android/lib/build-vosk.sh",
    "chars": 4674,
    "preview": "#!/bin/bash\n\n# Copyright 2019-2021 Alpha Cephei Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");"
  },
  {
    "path": "android/lib/build.gradle",
    "chars": 903,
    "preview": "def archiveName = \"vosk-android\"\ndef pomName = \"Vosk Android\"\ndef pomDescription = \"Vosk speech recognition library for "
  },
  {
    "path": "android/lib/src/main/AndroidManifest.xml",
    "chars": 61,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest>\n</manifest>"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/LibVosk.java",
    "chars": 3107,
    "preview": "package org.vosk;\n\nimport com.sun.jna.Native;\nimport com.sun.jna.Library;\nimport com.sun.jna.Platform;\nimport com.sun.jn"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/LogLevel.java",
    "chars": 369,
    "preview": "package org.vosk;\n\npublic enum LogLevel {\n    WARNINGS(-1),  // Print warning and errors\n    INFO(0),       // Print inf"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/Model.java",
    "chars": 487,
    "preview": "package org.vosk;\n\nimport java.io.IOException;\nimport com.sun.jna.PointerType;\n\npublic class Model extends PointerType i"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/Recognizer.java",
    "chars": 10114,
    "preview": "package org.vosk;\n\nimport com.sun.jna.PointerType;\nimport java.io.IOException;\n\npublic class Recognizer extends PointerT"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/SpeakerModel.java",
    "chars": 1145,
    "preview": "package org.vosk;\n\nimport com.sun.jna.PointerType;\nimport java.io.IOException;\n\n/**\n * Helps to initialize speaker recog"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/TextProcessor.java",
    "chars": 526,
    "preview": "package org.vosk;\n\nimport com.sun.jna.PointerType;\n\npublic class TextProcessor extends PointerType implements AutoClosea"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/android/RecognitionListener.java",
    "chars": 1190,
    "preview": "// Copyright 2019 Alpha Cephei Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/android/SpeechService.java",
    "chars": 8265,
    "preview": "// Copyright 2019 Alpha Cephei Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/android/SpeechStreamService.java",
    "chars": 5576,
    "preview": "// Copyright 2019 Alpha Cephei Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not"
  },
  {
    "path": "android/lib/src/main/java/org/vosk/android/StorageService.java",
    "chars": 5361,
    "preview": "// Copyright 2019 Alpha Cephei Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not"
  },
  {
    "path": "android/lib/src/main/jniLibs/arm64-v8a/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "android/lib/src/main/jniLibs/armeabi-v7a/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "android/lib/src/main/jniLibs/x86/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "android/lib/src/main/jniLibs/x86_64/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "android/model-en/build.gradle",
    "chars": 938,
    "preview": "def archiveName = \"vosk-model-en\"\ndef pomName = \"Vosk English Model\"\ndef pomDescription = \"Small English model for Andro"
  },
  {
    "path": "android/model-en/src/main/AndroidManifest.xml",
    "chars": 23,
    "preview": "<manifest>\n</manifest>\n"
  },
  {
    "path": "android/settings.gradle",
    "chars": 28,
    "preview": "include ':lib', ':model-en'\n"
  },
  {
    "path": "c/Makefile",
    "chars": 309,
    "preview": "CFLAGS=-I../src\nLDFLAGS=-L../src -lvosk -ldl -lpthread -Wl,-rpath,../src\n\nall: test_vosk test_vosk_speaker\n\ntest_vosk: t"
  },
  {
    "path": "c/test_vosk.c",
    "chars": 815,
    "preview": "#include <vosk_api.h>\n#include <stdio.h>\n\nint main() {\n    FILE *wavin;\n    char buf[3200];\n    int nread, final;\n\n    V"
  },
  {
    "path": "c/test_vosk_speaker.c",
    "chars": 910,
    "preview": "#include <vosk_api.h>\n#include <stdio.h>\n\nint main() {\n    FILE *wavin;\n    char buf[3200];\n    int nread, final;\n\n    V"
  },
  {
    "path": "csharp/README.md",
    "chars": 499,
    "preview": "This is a nuget-based wrapper for libvosk library\n\nSee demo folder for example how to use the library. You can simply ru"
  },
  {
    "path": "csharp/demo/VoskDemo.cs",
    "chars": 2688,
    "preview": "using System;\nusing System.IO;\nusing Vosk;\n\npublic class VoskDemo\n{\n   public static void DemoBytes(Model model)\n   {\n  "
  },
  {
    "path": "csharp/demo/VoskDemo.csproj",
    "chars": 396,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</Targe"
  },
  {
    "path": "csharp/nuget/Vosk.csproj",
    "chars": 494,
    "preview": "<Project Sdk=\"Microsoft.NET.Sdk\">\n\n  <PropertyGroup>\n    <TargetFramework>net8.0</TargetFramework>\n    <ImplicitUsings>e"
  },
  {
    "path": "csharp/nuget/Vosk.nuspec",
    "chars": 1904,
    "preview": "<?xml version=\"1.0\"?>\n<package>\n  <metadata>\n    <id>Vosk</id>\n    <version>0.3.75</version>\n    <authors>Alpha Cephei I"
  },
  {
    "path": "csharp/nuget/build/Vosk.targets",
    "chars": 646,
    "preview": "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <NativeLibs Include=\"$(MSBuildTh"
  },
  {
    "path": "csharp/nuget/build/lib/linux-x64/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "csharp/nuget/build/lib/osx-universal/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "csharp/nuget/build/lib/win-x64/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "csharp/nuget/build.sh",
    "chars": 101,
    "preview": "rm -rf bin lib obj\n/home/shmyrev/local/dotnet/dotnet pack Vosk.csproj -p:NuspecFile=Vosk.nuspec -o .\n"
  },
  {
    "path": "csharp/nuget/src/BatchModel.cs",
    "chars": 1518,
    "preview": "using System;\n\nnamespace Vosk\n{\n    public class BatchModel : global::System.IDisposable\n    {\n        private global::S"
  },
  {
    "path": "csharp/nuget/src/Model.cs",
    "chars": 1108,
    "preview": "namespace Vosk {\n\npublic class Model : global::System.IDisposable {\n  private global::System.Runtime.InteropServices.Han"
  },
  {
    "path": "csharp/nuget/src/SpkModel.cs",
    "chars": 1022,
    "preview": "namespace Vosk {\n\npublic class SpkModel : global::System.IDisposable {\n  private global::System.Runtime.InteropServices."
  },
  {
    "path": "csharp/nuget/src/Vosk.cs",
    "chars": 271,
    "preview": "namespace Vosk {\n\npublic class Vosk {\n  public static void SetLogLevel(int level) {\n    VoskPINVOKE.SetLogLevel(level);\n"
  },
  {
    "path": "csharp/nuget/src/VoskBatchRecognizer.cs",
    "chars": 2688,
    "preview": "using System;\n\nnamespace Vosk\n{\n    public class VoskBatchRecognizer : System.IDisposable\n    {\n        private System.R"
  },
  {
    "path": "csharp/nuget/src/VoskPINVOKE.cs",
    "chars": 8752,
    "preview": "namespace Vosk {\n\nclass VoskPINVOKE {\n\n  static VoskPINVOKE() {\n  }\n\n  [global::System.Runtime.InteropServices.DllImport"
  },
  {
    "path": "csharp/nuget/src/VoskRecognizer.cs",
    "chars": 3428,
    "preview": "namespace Vosk {\n\npublic enum EndpointerMode {\n    DEFAULT = 0,\n    SHORT = 1,\n    LONG = 2,\n    VERY_LONG = 3\n}\n\npublic"
  },
  {
    "path": "go/COPYING",
    "chars": 10173,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "go/README.md",
    "chars": 61,
    "preview": "See example subfolder for instructions how to use the module\n"
  },
  {
    "path": "go/batch.go",
    "chars": 2971,
    "preview": "package vosk\n\n// #cgo CPPFLAGS: -I ${SRCDIR}/../src\n// #cgo !windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -ldl -lpthread\n"
  },
  {
    "path": "go/batch_example/README.md",
    "chars": 332,
    "preview": "This example expects a `s16le` converted audio file and converts it to text in a\nmanner that imitates the Python example"
  },
  {
    "path": "go/batch_example/test_batch.go",
    "chars": 790,
    "preview": "package main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\n\tvosk \"github.com/alphacep/vosk-api/go\"\n)\n\nfunc main() {\n\tvar "
  },
  {
    "path": "go/doc.go",
    "chars": 412,
    "preview": "// Go bindings for Vosk speech recognition toolkit. Vosk is an offline\n// open source speech to text API for Android, iO"
  },
  {
    "path": "go/example/README.md",
    "chars": 1318,
    "preview": "To try this package do the following steps:\n\nOn Linux (we download library and set LD_LIBRARY_PATH)\n\n```\ngit clone https"
  },
  {
    "path": "go/example/doc.go",
    "chars": 54,
    "preview": "// Example package for Vosk Go bindings.\npackage main\n"
  },
  {
    "path": "go/example/test_simple.go",
    "chars": 985,
    "preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\n\tvosk \"github.com/alphacep/vosk-api/go\"\n)\n\nfu"
  },
  {
    "path": "go/go.mod",
    "chars": 103,
    "preview": "module github.com/alphacep/vosk-api/go\n\ngo 1.16\n\nreplace (\n    github.com/alphacep/vosk-api/go => ./\n)\n"
  },
  {
    "path": "go/vosk.go",
    "chars": 5794,
    "preview": "package vosk\n\n// #cgo CPPFLAGS: -I ${SRCDIR}/../src\n// #cgo !windows LDFLAGS: -L ${SRCDIR}/../src -lvosk -ldl -lpthread\n"
  },
  {
    "path": "ios/README",
    "chars": 136,
    "preview": "This is a baseline for the vosk-api iOS demo. It requires a build of a\nVosk-API library, mail contact@alphacephei.com fo"
  },
  {
    "path": "ios/VoskApiTest/AppDelegate.swift",
    "chars": 2181,
    "preview": "//\n//  AppDelegate.swift\n//  VoskApiTest\n//\n//  Created by Niсkolay Shmyrev on 01.03.20.\n//  Copyright © 2020 Alpha Ceph"
  },
  {
    "path": "ios/VoskApiTest/Assets.xcassets/AppIcon.appiconset/Contents.json",
    "chars": 1590,
    "preview": "{\n  \"images\" : [\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\""
  },
  {
    "path": "ios/VoskApiTest/Base.lproj/LaunchScreen.storyboard",
    "chars": 1740,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
  },
  {
    "path": "ios/VoskApiTest/Base.lproj/Main.storyboard",
    "chars": 4880,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
  },
  {
    "path": "ios/VoskApiTest/Info.plist",
    "chars": 1442,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
  },
  {
    "path": "ios/VoskApiTest/ViewController.swift",
    "chars": 3761,
    "preview": "//\n//  ViewController.swift\n//  VoskApiTest\n//\n//  Created by Niсkolay Shmyrev on 01.03.20.\n//  Copyright © 2020-2021 Al"
  },
  {
    "path": "ios/VoskApiTest/Vosk/vosk_api.h",
    "chars": 10234,
    "preview": "// Copyright 2020-2021 Alpha Cephei Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you ma"
  },
  {
    "path": "ios/VoskApiTest/Vosk.swift",
    "chars": 1699,
    "preview": "//\n//  Vosk.swift\n//  VoskApiTest\n//\n//  Created by Niсkolay Shmyrev on 01.03.20.\n//  Copyright © 2020-2021 Alpha Cephei"
  },
  {
    "path": "ios/VoskApiTest/VoskModel.swift",
    "chars": 802,
    "preview": "//\n//  Vosk.swift\n//  VoskApiTest\n//\n//  Created by Niсkolay Shmyrev on 01.03.20.\n//  Copyright © 2020-2021 Alpha Cephei"
  },
  {
    "path": "ios/VoskApiTest/bridging.h",
    "chars": 26,
    "preview": "#import \"Vosk/vosk_api.h\"\n"
  },
  {
    "path": "ios/VoskApiTest.xcodeproj/project.pbxproj",
    "chars": 17560,
    "preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
  },
  {
    "path": "ios/VoskApiTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "chars": 135,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:\">\n   </FileRef"
  },
  {
    "path": "java/README.md",
    "chars": 208,
    "preview": "Java bindings for Vosk API using jnr-ffi\n\nSee demo project for details, build it with Gradle.\n\nDownload model and unpack"
  },
  {
    "path": "java/demo/build.gradle",
    "chars": 226,
    "preview": "plugins {\n    id 'application'\n}\n\napplication {\n    mainClass = 'org.vosk.demo.DecoderDemo'\n}\n\nrepositories {\n    mavenC"
  },
  {
    "path": "java/demo/src/main/java/org/vosk/demo/DecoderDemo.java",
    "chars": 1239,
    "preview": "package org.vosk.demo;\n\nimport java.io.FileInputStream;\nimport java.io.BufferedInputStream;\nimport java.io.IOException;\n"
  },
  {
    "path": "java/lib/build.gradle",
    "chars": 1645,
    "preview": "buildscript {\n  repositories {\n    mavenCentral()\n  }\n}\n\nplugins {\n    id 'java-library'\n    id 'maven-publish'\n    id '"
  },
  {
    "path": "java/lib/src/main/java/org/vosk/LibVosk.java",
    "chars": 4264,
    "preview": "package org.vosk;\n\nimport com.sun.jna.Native;\nimport com.sun.jna.Platform;\nimport com.sun.jna.Pointer;\nimport java.io.Fi"
  },
  {
    "path": "java/lib/src/main/java/org/vosk/LogLevel.java",
    "chars": 369,
    "preview": "package org.vosk;\n\npublic enum LogLevel {\n    WARNINGS(-1),  // Print warning and errors\n    INFO(0),       // Print inf"
  },
  {
    "path": "java/lib/src/main/java/org/vosk/Model.java",
    "chars": 487,
    "preview": "package org.vosk;\n\nimport java.io.IOException;\nimport com.sun.jna.PointerType;\n\npublic class Model extends PointerType i"
  },
  {
    "path": "java/lib/src/main/java/org/vosk/Recognizer.java",
    "chars": 10114,
    "preview": "package org.vosk;\n\nimport com.sun.jna.PointerType;\nimport java.io.IOException;\n\npublic class Recognizer extends PointerT"
  },
  {
    "path": "java/lib/src/main/java/org/vosk/SpeakerModel.java",
    "chars": 1145,
    "preview": "package org.vosk;\n\nimport com.sun.jna.PointerType;\nimport java.io.IOException;\n\n/**\n * Helps to initialize speaker recog"
  },
  {
    "path": "java/lib/src/main/resources/darwin/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "java/lib/src/main/resources/linux-x86-64/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "java/lib/src/main/resources/win32-x86-64/.keep-me",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "java/lib/src/main/resources/win32-x86-64/empty",
    "chars": 31,
    "preview": "Mainly for work around JNA API\n"
  },
  {
    "path": "java/lib/src/test/java/org/vosk/test/DecoderTest.java",
    "chars": 4307,
    "preview": "package org.vosk.test;\n\nimport java.io.FileInputStream;\nimport java.io.BufferedInputStream;\nimport java.io.IOException;\n"
  },
  {
    "path": "kotlin/.gitignore",
    "chars": 22,
    "preview": ".gradle/\n.idea/\nbuild/"
  },
  {
    "path": "kotlin/AUTHORS",
    "chars": 31,
    "preview": "Doomsdayrs doomsdayrs@gmail.com"
  },
  {
    "path": "kotlin/MAINTENANCE.md",
    "chars": 357,
    "preview": "# Maintenance\n\nTo maintain this module, please ensure the following.\n1. Kotlin version is kept up to date.\nThis will be "
  },
  {
    "path": "kotlin/README.md",
    "chars": 2078,
    "preview": "# vosk-api-kotlin\n\nThe vosk-api wrapped using Kotlin Multiplatform.\n\n## Usage\n\nThe following are ways to use this wrappe"
  },
  {
    "path": "kotlin/build.gradle.kts",
    "chars": 5201,
    "preview": "import org.jetbrains.dokka.gradle.DokkaTask\nimport org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi\nimport "
  },
  {
    "path": "kotlin/settings.gradle.kts",
    "chars": 895,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/androidMain/AndroidManifest.xml",
    "chars": 230,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package="
  },
  {
    "path": "kotlin/src/androidMain/kotlin/org/vosk/android/RecognitionListener.kt",
    "chars": 1118,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/androidMain/kotlin/org/vosk/android/SpeechService.kt",
    "chars": 6582,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/androidMain/kotlin/org/vosk/android/SpeechStreamService.kt",
    "chars": 4389,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/androidMain/kotlin/org/vosk/android/StorageService.kt",
    "chars": 4172,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/AcceptWaveformException.kt",
    "chars": 777,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/BatchModel.kt",
    "chars": 984,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/BatchRecognizer.kt",
    "chars": 1336,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/EndPointerMode.kt",
    "chars": 735,
    "preview": "/*\n * Copyright 2024 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/Freeable.kt",
    "chars": 842,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/LogLevel.kt",
    "chars": 913,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/Model.kt",
    "chars": 1617,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/Recognizer.kt",
    "chars": 8836,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/SpeakerModel.kt",
    "chars": 1336,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/TextProcessor.kt",
    "chars": 910,
    "preview": "/*\n * Copyright 2024 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/Vosk.kt",
    "chars": 1202,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/exception/IOException.kt",
    "chars": 764,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/exception/ModelException.kt",
    "chars": 772,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/exception/RecognizerException.kt",
    "chars": 758,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/json/Alternative.kt",
    "chars": 865,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/json/Extension.kt",
    "chars": 1698,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/json/PartialResultOutput.kt",
    "chars": 924,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/json/Result.kt",
    "chars": 866,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/json/ResultOutput.kt",
    "chars": 881,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/commonMain/kotlin/org/vosk/json/WaveformResult.kt",
    "chars": 1149,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/BatchModel.kt",
    "chars": 1815,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/BatchRecognizer.kt",
    "chars": 2096,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/LibVosk.kt",
    "chars": 5564,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/Model.kt",
    "chars": 2493,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/Recognizer.kt",
    "chars": 11056,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/SpeakerModel.kt",
    "chars": 2202,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/TextProcessor.kt",
    "chars": 1213,
    "preview": "/*\n * Copyright 2024 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/Vosk.kt",
    "chars": 1378,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/WaveformExt.kt",
    "chars": 1795,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmMain/kotlin/org/vosk/exception/IOException.kt",
    "chars": 723,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/jvmTest/kotlin/DecoderTest.kt",
    "chars": 5730,
    "preview": "/*\n * Copyright 2023 Alpha Cephei Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may "
  },
  {
    "path": "kotlin/src/nativeInterop/cinterop/libvosk.def",
    "chars": 489,
    "preview": "headers = libvosk/vosk_api.h\npackage = libvosk\n\nnoStringConversion = \\\n\tvosk_batch_recognizer_accept_waveform \\\n\tvosk_re"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/BatchModel.kt",
    "chars": 1324,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/BatchRecognizer.kt",
    "chars": 2083,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/FreeableExt.kt",
    "chars": 788,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/IOException.kt",
    "chars": 93,
    "preview": "package org.vosk\n\nactual class IOException actual constructor(message: String?) : Exception()"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/Model.kt",
    "chars": 1933,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/Recognizer.kt",
    "chars": 9750,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/SpeakerModel.kt",
    "chars": 1584,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/Utils.kt",
    "chars": 755,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "kotlin/src/nativeMain/kotlin/org/vosk/Vosk.kt",
    "chars": 1379,
    "preview": "/*\n * Copyright 2020 Alpha Cephei Inc. & Doomsdayrs\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\")"
  },
  {
    "path": "nodejs/.npmignore",
    "chars": 40,
    "preview": "demo/model\ndemo/model-spk\ndemo/test.wav\n"
  },
  {
    "path": "nodejs/README.md",
    "chars": 1260,
    "preview": "This is an FFI-NAPI wrapper for the Vosk library.\n\n## Usage\n\nBindings mostly follow Vosk interface, some methods are not"
  },
  {
    "path": "nodejs/demo/test_ffmpeg.js",
    "chars": 1007,
    "preview": "var vosk = require('..')\n\nconst fs = require(\"fs\");\nconst { spawn } = require(\"child_process\");\n\nMODEL_PATH = \"model\"\nFI"
  },
  {
    "path": "nodejs/demo/test_microphone.js",
    "chars": 1075,
    "preview": "var vosk = require('..')\n\nconst fs = require(\"fs\");\nvar mic = require(\"mic\");\n\nMODEL_PATH = \"model\"\nSAMPLE_RATE = 16000\n"
  },
  {
    "path": "nodejs/demo/test_simple.js",
    "chars": 1472,
    "preview": "var vosk = require('..')\n\nconst fs = require(\"fs\");\nconst { Readable } = require(\"stream\");\nconst wav = require(\"wav\");\n"
  },
  {
    "path": "nodejs/demo/test_simple_async.js",
    "chars": 1490,
    "preview": "var vosk = require('..')\n\nconst async = require(\"async\");\nconst fs = require(\"fs\");\nconst { Readable } = require(\"stream"
  },
  {
    "path": "nodejs/demo/test_speaker.js",
    "chars": 1787,
    "preview": "const vosk = require('..');\n\nconst fs = require(\"fs\");\nconst { Readable } = require(\"stream\");\nconst wav = require(\"wav\""
  },
  {
    "path": "nodejs/demo/test_srt.js",
    "chars": 2532,
    "preview": "var vosk = require('..')\n\nconst fs = require(\"fs\");\nconst { spawn } = require(\"child_process\");\nconst { stringifySync } "
  },
  {
    "path": "nodejs/index.js",
    "chars": 14774,
    "preview": "// @ts-check\n'use strict'\n\n/**\n * @module vosk\n */\n\nconst os = require('os');\nconst path = require('path');\n/** @type {i"
  },
  {
    "path": "nodejs/package.json",
    "chars": 573,
    "preview": "{\n  \"name\": \"vosk\",\n  \"version\": \"0.3.75\",\n  \"description\": \"Node binding for continuous offline voice recoginition with"
  },
  {
    "path": "python/.pylintrc",
    "chars": 21096,
    "preview": "[MAIN]\n\n# Analyse import fallback blocks. This can be used to support both Python 2 and\n# 3 compatible code, which means"
  },
  {
    "path": "python/README.md",
    "chars": 1046,
    "preview": "This is a Python module for Vosk.\n\nVosk is an offline open source speech recognition toolkit. It enables\nspeech recognit"
  },
  {
    "path": "python/example/colab/kaldi-build.ipynb",
    "chars": 2786526,
    "preview": "{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 0,\n  \"metadata\": {\n    \"colab\": {\n      \"name\": \"Vosk Kaldi Build\",\n      \"proven"
  },
  {
    "path": "python/example/colab/vosk-adaptation.ipynb",
    "chars": 39038,
    "preview": "{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 0,\n  \"metadata\": {\n    \"colab\": {\n      \"name\": \"Vosk Adaptation\",\n      \"provena"
  },
  {
    "path": "python/example/colab/vosk-training.ipynb",
    "chars": 286490,
    "preview": "{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 0,\n  \"metadata\": {\n    \"colab\": {\n      \"name\": \"Vosk Training\",\n      \"provenanc"
  },
  {
    "path": "python/example/colab/vosk.ipynb",
    "chars": 385148,
    "preview": "{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 0,\n  \"metadata\": {\n    \"colab\": {\n      \"name\": \"Vosk Colab Demo\",\n      \"provena"
  },
  {
    "path": "python/example/test_alternatives.py",
    "chars": 688,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport sys\nimport json\n\nfrom vosk import Model, KaldiRecognizer, SetLogLevel\n\nSetLog"
  },
  {
    "path": "python/example/test_empty.py",
    "chars": 189,
    "preview": "#!/usr/bin/env python3\n\nimport json\n\nfrom vosk import Model, KaldiRecognizer\n\nmodel = Model(lang=\"en-us\")\nrec = KaldiRec"
  },
  {
    "path": "python/example/test_ep.py",
    "chars": 1340,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport sys\n\nfrom vosk import Model, KaldiRecognizer, SetLogLevel, EndpointerMode\n\n# "
  },
  {
    "path": "python/example/test_ffmpeg.py",
    "chars": 724,
    "preview": "#!/usr/bin/env python3\n\nimport subprocess\nimport sys\n\nfrom vosk import Model, KaldiRecognizer, SetLogLevel\n\nSAMPLE_RATE "
  },
  {
    "path": "python/example/test_gpu_batch.py",
    "chars": 1411,
    "preview": "#!/usr/bin/env python3\n\nimport sys\nimport json\n\nfrom vosk import BatchModel, BatchRecognizer, GpuInit\nfrom timeit import"
  },
  {
    "path": "python/example/test_gradio.py",
    "chars": 934,
    "preview": "#!/usr/bin/env python3\n\nimport json\nimport gradio as gr\n\nfrom vosk import KaldiRecognizer, Model\n\nmodel = Model(lang=\"en"
  },
  {
    "path": "python/example/test_itn.py",
    "chars": 317,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport sys\n\nfrom vosk import Processor\n\nproc = Processor(\"ru_itn_tagger.fst\", \"ru_it"
  },
  {
    "path": "python/example/test_microphone.py",
    "chars": 2822,
    "preview": "#!/usr/bin/env python3\n\n# prerequisites: as described in https://alphacephei.com/vosk/install and also python module `so"
  },
  {
    "path": "python/example/test_nlsml.py",
    "chars": 595,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport sys\n\nfrom vosk import Model, KaldiRecognizer, SetLogLevel\n\nSetLogLevel(0)\n\nwf"
  },
  {
    "path": "python/example/test_reset.py",
    "chars": 775,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport sys\nimport json\n\nfrom vosk import Model, KaldiRecognizer, SetLogLevel\n\nSetLog"
  },
  {
    "path": "python/example/test_simple.py",
    "chars": 834,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport sys\n\nfrom vosk import Model, KaldiRecognizer, SetLogLevel\n\n# You can set log "
  },
  {
    "path": "python/example/test_speaker.py",
    "chars": 3345,
    "preview": "#!/usr/bin/env python3\n\nimport os\nimport sys\nimport wave\nimport json\nimport numpy as np\n\nfrom vosk import Model, KaldiRe"
  },
  {
    "path": "python/example/test_srt.py",
    "chars": 529,
    "preview": "#!/usr/bin/env python3\n\nimport subprocess\nimport sys\n\nfrom vosk import Model, KaldiRecognizer, SetLogLevel\n\nSAMPLE_RATE "
  },
  {
    "path": "python/example/test_text.py",
    "chars": 668,
    "preview": "#!/usr/bin/env python3\n\nimport sys\nimport json\n\nfrom vosk import Model, KaldiRecognizer\n\nmodel = Model(lang=\"en-us\")\n\n# "
  },
  {
    "path": "python/example/test_webvtt.py",
    "chars": 1770,
    "preview": "#!/usr/bin/env python3\n\nimport sys\nimport subprocess\nimport json\nimport textwrap\n\nfrom webvtt import WebVTT, Caption\nfro"
  },
  {
    "path": "python/example/test_words.py",
    "chars": 864,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport sys\n\nfrom vosk import Model, KaldiRecognizer\n\nwf = wave.open(sys.argv[1], \"rb"
  },
  {
    "path": "python/setup.py",
    "chars": 2861,
    "preview": "import os\nimport setuptools\nimport shutil\nimport glob\nimport platform\n\n# Figure out environment for cross-compile\nvosk_s"
  },
  {
    "path": "python/test/transcribe_scp.py",
    "chars": 774,
    "preview": "#!/usr/bin/env python3\n\nimport wave\nimport json\nimport sys\n\nfrom multiprocessing.dummy import Pool\nfrom vosk import Mode"
  },
  {
    "path": "python/vosk/__init__.py",
    "chars": 10754,
    "preview": "import os\nimport sys\nimport srt\nimport datetime\nimport json\nimport enum\n\nimport requests\nfrom urllib.request import urlr"
  },
  {
    "path": "python/vosk/transcriber/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "python/vosk/transcriber/cli.py",
    "chars": 2689,
    "preview": "#!/usr/bin/env python3\n\nimport argparse\nimport logging\nimport sys\nimport os\n\nfrom pathlib import Path\nfrom vosk import l"
  },
  {
    "path": "python/vosk/transcriber/transcriber.py",
    "chars": 7338,
    "preview": "import json\nimport logging\nimport asyncio\nimport websockets\nimport srt\nimport datetime\nimport shlex\nimport subprocess\n\nf"
  },
  {
    "path": "python/vosk_builder.py",
    "chars": 332,
    "preview": "#!/usr/bin/env python3\n\nimport os\nfrom cffi import FFI\n\nvosk_root=os.environ.get(\"VOSK_SOURCE\", \"..\")\ncpp_command = \"cpp"
  },
  {
    "path": "ruby/.gitignore",
    "chars": 119,
    "preview": "/.bundle/\n/.yardoc\n/_yardoc/\n/coverage/\n/doc/\n/pkg/\n/spec/reports/\n/tmp/\n\n# rspec failure tracking\n.rspec_status\n.idea\n"
  },
  {
    "path": "ruby/.rspec",
    "chars": 53,
    "preview": "--format documentation\n--color\n--require spec_helper\n"
  },
  {
    "path": "ruby/.rubocop.yml",
    "chars": 867,
    "preview": "plugins:\n - rubocop-rake\n - rubocop-rspec\n\nAllCops:\n  TargetRubyVersion: 2.5\n  NewCops: enable\n\nStyle/StringLiterals:\n  "
  },
  {
    "path": "ruby/Gemfile",
    "chars": 305,
    "preview": "# frozen_string_literal: true\n\nsource \"https://rubygems.org\"\n\n# Specify your gem's dependencies in vosk.gemspec\ngemspec\n"
  },
  {
    "path": "ruby/README.md",
    "chars": 3162,
    "preview": "# Vosk Ruby\n\nRuby bindings for [Vosk](https://alphacephei.com/vosk/) — an offline speech recognition toolkit supporting "
  },
  {
    "path": "ruby/Rakefile",
    "chars": 1844,
    "preview": "# frozen_string_literal: true\n\nrequire \"bundler/gem_tasks\"\nrequire \"rspec/core/rake_task\"\nrequire \"rubygems/package_task"
  },
  {
    "path": "ruby/bin/console",
    "chars": 278,
    "preview": "#!/usr/bin/env ruby\n# frozen_string_literal: true\n\nrequire \"bundler/setup\"\nrequire \"vosk\"\n\n# You can add fixtures and/or"
  },
  {
    "path": "ruby/bin/setup",
    "chars": 131,
    "preview": "#!/usr/bin/env bash\nset -euo pipefail\nIFS=$'\\n\\t'\nset -vx\n\nbundle install\n\n# Do any other automated setup that you need "
  },
  {
    "path": "ruby/example/test_simple.rb",
    "chars": 988,
    "preview": "#!/usr/bin/env ruby\n# frozen_string_literal: true\n\nrequire \"vosk\"\nrequire \"wavefile\"\n\n# You can set log level to -1 to d"
  },
  {
    "path": "ruby/example/test_srt.rb",
    "chars": 395,
    "preview": "#!/usr/bin/env ruby\n# frozen_string_literal: true\n\nrequire \"vosk\"\n\nSAMPLE_RATE = 16_000\n\nVosk.log_level = -1\n\nmodel = Vo"
  },
  {
    "path": "ruby/example/test_words.rb",
    "chars": 1012,
    "preview": "#!/usr/bin/env ruby\n# frozen_string_literal: true\n\nrequire \"vosk\"\nrequire \"wavefile\"\n\nWaveFile::Reader.new(ARGV[0]) do |"
  },
  {
    "path": "ruby/exe/vosk-transcriber",
    "chars": 73,
    "preview": "#!/usr/bin/env ruby\n# frozen_string_literal: true\n\nrequire \"vosk\"\n# TODO\n"
  },
  {
    "path": "ruby/lib/vosk/ffi.rb",
    "chars": 6851,
    "preview": "# frozen_string_literal: true\n\nrequire \"ffi\"\n\nmodule Vosk\n  module C # :nodoc: all\n    extend FFI::Library\n\n    # FIXME:"
  },
  {
    "path": "ruby/lib/vosk/progressbar.rb",
    "chars": 1870,
    "preview": "# frozen_string_literal: true\n\nrequire \"progressbar\"\nrequire \"bytesize\"\n\n# Extends progressbar with tqdm-like output:\n# "
  },
  {
    "path": "ruby/lib/vosk/version.rb",
    "chars": 68,
    "preview": "# frozen_string_literal: true\n\nmodule Vosk\n  VERSION = \"0.3.45\"\nend\n"
  },
  {
    "path": "ruby/lib/vosk.rb",
    "chars": 10379,
    "preview": "# frozen_string_literal: true\n\nrequire_relative \"vosk/version\"\nrequire \"httparty\"\nrequire_relative \"vosk/progressbar\"\nre"
  },
  {
    "path": "ruby/sig/vosk.rbs",
    "chars": 103,
    "preview": "module Vosk\n  VERSION: String\n  # See the writing guide of rbs: https://github.com/ruby/rbs#guides\nend\n"
  },
  {
    "path": "ruby/spec/spec_helper.rb",
    "chars": 412,
    "preview": "# frozen_string_literal: true\n\nrequire \"vosk\"\nrequire \"webmock/rspec\"\n\nRSpec.configure do |config|\n  # Enable flags like"
  },
  {
    "path": "ruby/spec/vosk/model_spec.rb",
    "chars": 6544,
    "preview": "# frozen_string_literal: true\n\nRSpec.describe Vosk::Model do\n  let(:tmpdir) { Dir.mktmpdir }\n  let(:en_model_path) { Fil"
  },
  {
    "path": "ruby/spec/vosk_spec.rb",
    "chars": 5984,
    "preview": "# frozen_string_literal: true\n\nrequire \"json\"\nrequire \"srt\"\nrequire \"wavefile\"\n\nRSpec.describe Vosk do\n  let(:en_model_p"
  },
  {
    "path": "ruby/vosk.gemspec",
    "chars": 1663,
    "preview": "# frozen_string_literal: true\n\nrequire_relative \"lib/vosk/version\"\n\nGem::Specification.new do |spec|\n  spec.name = \"vosk"
  },
  {
    "path": "rust/README.md",
    "chars": 71,
    "preview": "See\n\nhttps://github.com/Bear-03/vosk-rs\n\nhttps://crates.io/crates/vosk\n"
  },
  {
    "path": "src/Makefile",
    "chars": 3447,
    "preview": "# Locations of the dependencies\nKALDI_ROOT?=$(HOME)/travis/kaldi\nOPENFST_ROOT?=$(KALDI_ROOT)/tools/openfst\nOPENBLAS_ROOT"
  },
  {
    "path": "src/batch_model.cc",
    "chars": 5612,
    "preview": "// Copyright 2019-2020 Alpha Cephei Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you ma"
  }
]

// ... and 55 more files (download for full content)

About this extraction

This page contains the full source code of the alphacep/vosk-api GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 255 files (3.9 MB), approximately 1.0M tokens, and a symbol index with 578 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!