Prerequisites

  • Unity 2023.2 or later (Unity 6 recommended)
  • iOS Build Support module installed in Unity Hub
  • Android Build Support module installed in Unity Hub (includes SDK, NDK, JDK)

1. Download the Plugin

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

2. Unpack the Archive

Unpack the plugin archive into your Unity project root:

tar xzf KeenASR-Unity-CUSTOMER-vVERSION-HASH.tgz -C /path/to/your/unity/project

This creates the following structure in your project:

Assets/
  Plugins/
    KeenASR/             C# scripts, native bridges, SDK frameworks
      iOS/               KeenASR.xcframework, KeenASRBridge.m
      Android/           KeenASR.aar, KeenASRAndroidUnityBindings.aar
      Editor/            PostBuildProcess.cs (iOS post-build automation)
  StreamingAssets/
    keenA1m-nnet3chain-en-us/  ASR bundle (acoustic model)

The archive also includes Assets/TestKeenASR.cs, a sample scene controller that demonstrates initialization, decoding graph creation, listening, and result handling. You can use it for quick verification or remove it once you have integrated the plugin into your own code.

Using TestKeenASR.cs for a Quick Test

When creating a new project for testing, the Universal 3D template is a good starting point.

  1. Open your Unity project
  2. Create a new scene (or use the default scene)
  3. Create an empty GameObject (GameObject > Create Empty)
  4. Drag Assets/TestKeenASR.cs onto the GameObject to attach it
  5. Make sure the scene has a Camera (the script uses Camera.main)
  6. Build and run on a device or simulator

The sample app shows a Start Listening button. Tap it, say one of the color words (e.g. “RED”, “BLUE”, “GREEN”), and the recognized text appears on screen.

3. Microphone Permission

iOS: Handled automatically. The plugin’s PostBuildProcess.cs adds NSMicrophoneUsageDescription to the Xcode project’s Info.plist during build. Review and edit the description in this file as needed.

Android: The RECORD_AUDIO permission is declared in the KeenASR AAR’s manifest and merged automatically during the Android build. Runtime permission must still be requested in code (see Quick Start).

4. Verify the Setup

Build and run on a device (or iOS Simulator with Unity 6 on Apple Silicon). You should see log output:

Keen: Initializing KeenASR Plugin

If initialization fails, check that:

  • The ASR bundle exists in StreamingAssets/ and the name matches exactly
  • Microphone permission is granted

Platform Notes

iOS:

  • KeenASR.xcframework is automatically embedded and signed by PostBuildProcess.cs
  • iOS Simulator requires Unity 6 on Apple Silicon (arm64); Unity 2023 only has x86_64 simulator support, which is not compatible with the KeenASR framework

Android:

  • IL2CPP scripting backend is required for ARM64 builds
  • The ASR bundle is automatically copied from StreamingAssets to internal storage on first launch
  • Initialization is asynchronous on Android. Always wait for the onInitializedReceived callback before using the recognizer

Upgrading from a previous plugin version: We recommend completely removing the old plugin (Assets/Plugins/KeenASR directory) before installing the new version.