Unity Plugin

KeenASR Unity is a beta release Unity plugin that encapsulates speech recognition functionality of Keen ASR SDK and provides simple-to-use C# interface via KeenASR class. Unity plugin currently works with both iOS and Android versions of KeenASR SDK. Keen ASR SDK will only work on the device (not the simulator) on those platforms; we provide stub methods for Unity Player.

Installing KeenASR Unity Plugin (tested in Unity 2017.2.0f3)

Download the latest archive file for the Unity plugin. The archive contains both Android and iOS SDKs as well as the ASR Bundle.

Unpack the archive in your Unity project root directory. You should end up with Assets/Plugins/KeenASR directory in your project; the archive also contains Assets/StreamingAssets/keenB2mQT-nnet3chain-en-us directory with the ASR Bundle (acoustic models) which are needed by KeenASR SDK.

Make sure Unity is setup to build for iOS or Android; editor version of the plugin provides only stubs.

As of plugin version 0.3 all settings in XCode that are related to KeenASR SDK are performed automatically via Assets/Plugins/KeenASR/Editor/PostBuildProcess.cs script. Please review and edit settings for microphone usage description in this file.

For Android builds, please modify the following settings under Build Settings -> Player Settings:

Device Filter: choose Armv7

Minimum API Level: 21

For Android builds, AndroidManifest.xml file in Assets/Plugins/KeenASR/Android/KeenASRUnityBinding.aar archive is setup to require RECORD_AUDIO permission. This file will be merged with the app’s AndroidManifest.xml file during Unity build and user will be prompted to allow the app to record the audio on application startup. The app will also prompt user for variety of additional permissions; if you disable, so called, “dangerous permissions” by creating your own AndroidManifest.xml file in Assets/Plugins/Android directory, you will need to make sure user is prompted for the record audio permissions before KeenASR SDK is initialized. For more details, please see Unity documentation.

If you are using a custom ASR Bundle provided by Keen Research please remove Assets/StreamingAssets/keenB2mQT/ directory and copy the custom ASR bundle instead so that StreamingAssets directory contains subdirectory with the new bundle.

If upgrading from previous plugin versions, we recommend you completely remove the old plugin (Assets/Plugins/KeenASR directory) and then install the new version of the plugin.

Warning: Speech recognition will only work on real iOS devices. Only stub methods are available for the editor version of the plugin.

Adding Speech Recognition Functionality to Your App

Review Assets/Plugins/KeenASR/KeenASR.cs file, which provides high-level interface to the SDK. We highly recommend you review the documentation for the iOS framework to get familiar with the high-level concepts. Unity plugin provides access to most of the functionality available in the iOS framework.

See sample code for using the plugin from within Unity. This sample shows how to initialize the SDK; it presents a “Start Listening” button on the screen and logs partial and final results on the console (they are not shown on the screen).

Note: Size of the KeenASR plugin is substantial because the plugin includes libraries for both iOS and Android, as well as the ASR Bundle (acoustic models). Only ASR Bundle is copied to the device; when libraries are linked against your app, linker typically strips out code that’s not being used, so the increment in the app size due to our SDK will be minimal.

ABOUT US

Keen Research is a privately owned company located in scenic Sausalito, just a few miles north of San Francisco. We develop SDKs and software tools for on-device speech recognition on mobile devices and custom hardware platforms. Our solution is used in a variety of applications, across many industry verticals.