Unity Plugin Document

KeenASR is a beta release Unity plugin that encapsulates speech recognition functionality and provides simple-to-use C# interface via KeenASR class. Our speech recognition SDK, and consenquently the plugin, currently supports only the iOS platform.

Installing KeenASR Unity Plugin (tested in Unity 5.5.1)

  1. Download the latest archive file for the plugin.

  2. Unpack the archive in your Unity project root directory. You should end up with Assets/Plugins/KeenASR directory in your project.

  3. Make sure Unity is setup to build for iOS (editor version of the plugin provides only stubs)

  4. 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. Current version of the plugin also contains librispeech-nnet2-en-us ASR Bundle, which will be automatically added to the XCode project via PostBuildProcess.cs script; if you decide not to keep the bundle directory in the Assets/Plugins/KeenASR folder, please make sure correct path to the directory is specified in PostBuildProcess.cs file.

  5. If you are using a custom ASR Bundle provided by Keen Research you can just modify the path in PostBuildProcess.cs to point to the correponding directory

  6. If upgrading from previous plugin versions, we recommend you completely remove the old plugin (Assets/Plugins/KeenASR and Assets/Plugins/iOS directories) and then install the new version of the plugin. You will also need to make sure that SetLogLevel is called as class method; we recommend you set the log level before initializing the SDK.

NOTE: editor version of the plugin is not available (stub methods are available, so you will be able to compile but speech recognition will only work on iOS devices)

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 SDK 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.


Release Log

Version 0.4, Septembar 26th, 2017

  • Enhancement: we reduced the memory footprint of the recognizer by about 20%. In addition, version 1.3 of the SDK supports quantized ASR Bundles which take 3-3.5x less disk space. Currently, this 3-3.5x reduction in ASR Bundle size only applies for on-disk storage (i.e. affecting your app download size). Future releases will follow similar reduction in memory footprint.

  • Enhacement / Bug fix: we introduced recognizerState readonly property for KeenASR instances, which you can access via GetRecognizerState method. This is replacing IsListening method which was not providing sufficient information.

  • Feature: you can now direct SDK to perform echo cancellation, if available on the device, to remove audio played by the app speaker from the signal captured by the microphone. For details see PerformEchoCancellation: and IsEchoCancellationAvailable methods of the KeenASR class. This feature is experimental.

  • Bug fix: cleanup of the audio interruption logic that was causing crashes on older iOSes and prevented compilation with older versions of XCode. The current implementation takes complete control of AVAudioSession management and provides two callback methods that allow developers to: 1) cleanup audio playing resources (stop playing audio, remember app state as necessary) before the app goes to the background. This allows us to properly deactivate AVAudioSession before app goes to background, 2) setup UI, etc. after audio interrupt is over and the app comes to foreground. Currently, when the app is about to go to the background the SDK will deactivate audio session, and then reactivate it when the app comes back to the foreground. See RecognizerReadyToListenAfterInterruptHandler callback method, which you can use to setup UI after the app comes to the foreground.

  • Bug fix: SDK crashes if PrepareForListeningWithCustomDecodingGraph is called while the app is listening. This is now fixed.


Version 0.3, August 14th, 2017

  • Enhancement: added PostBuildProcess.cs script which automates XCode settings updates

  • Enhancement: added stub methods for the Editor build, so that you can compile editor version of your app (KeenASR SDK will not function, but you will be able to create builds)

  • Enhancement: reorganized structure of the plugin, so that everything related to KeenASR plugin is stored in Assets/Plugins/KeenASR directory

  • Enhancement: added default ASR Bundle in the plugin so that it does not need to be downloaded separately

  • Enhancement: changes SetLogLevel method to be a static method of KeenASR class. This allows you to set the log level before the framework is initialized

  • Bug fix: fixed issue with KeenASR class (and sharedInstance) persisting across multiple scenes