vui_plugin 0.1.0 copy "vui_plugin: ^0.1.0" to clipboard
vui_plugin: ^0.1.0 copied to clipboard

PlatformAndroid

A Flutter plugin for Voice User Interface (VUI) using Android Accessibility Service. Provides on-device speech recognition with rule-based NLP for Indonesian language, enabling voice-controlled naviga [...]

VUI Plugin #

A Flutter plugin for Voice User Interface (VUI) using Android Accessibility Service. Provides fully on-device speech recognition with rule-based NLP for Indonesian language, enabling voice-controlled navigation, form filling, and command execution in Flutter apps.

pub package License: MIT

Features #

  • πŸŽ™οΈ On-device speech recognition β€” Prefers offline processing for speed and privacy
  • 🧠 Rule-based NLP β€” Indonesian keyword spotting & slot filling, no cloud dependency
  • β™Ώ Accessibility Service β€” Uses Android Accessibility Button for system-wide voice activation
  • πŸ“‘ Event-driven architecture β€” Pub/sub pattern via EventBus for loose coupling
  • πŸ”„ Auto-retry & watchdog β€” Robust error recovery with automatic retries on transient failures
  • πŸ“± Context-aware commands β€” Different voice commands available per screen
  • πŸ—£οΈ Live transcription β€” Real-time partial speech results for responsive UI feedback

Architecture #

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Flutter App                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ VuiPlugin  │◀──│ Platform │◀──│  Method    β”‚ β”‚
β”‚  β”‚ (Dart API) β”‚   β”‚ Interfaceβ”‚   β”‚  Channel   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              Android Native           β”‚         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Accessibility   │──▢│    VuiEventBus      β”‚ β”‚
β”‚  β”‚ Service         β”‚   β”‚    (Pub/Sub)        β”‚ β”‚
β”‚  β”‚ + SpeechRecog.  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚             β”‚
β”‚          β”‚                β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚          └───────────────▢│   NlpEngine     β”‚  β”‚
β”‚                           β”‚ (Keyword Spot + β”‚  β”‚
β”‚                           β”‚  Slot Filling)  β”‚  β”‚
β”‚                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Getting Started #

Installation #

Add to your pubspec.yaml:

dependencies:
  vui_plugin:
    path: packages/vui_plugin  # or from pub.dev

Android Setup #

1. Create Accessibility Service Config

Create android/app/src/main/res/xml/accessibility_service_config.xml:

<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityFlags="flagDefault|flagRequestAccessibilityButton"
    android:accessibilityFeedbackType="feedbackGeneric"
    android:notificationTimeout="100"
    android:canRetrieveWindowContent="false"
    android:description="@string/accessibility_service_description"
    android:settingsActivity="com.example.app.MainActivity" />

2. Register in AndroidManifest.xml

<service
    android:name="com.example.vui_plugin.VuiAccessibilityService"
    android:exported="true"
    android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
    <intent-filter>
        <action android:name="android.accessibilityservice.AccessibilityService" />
    </intent-filter>
    <meta-data
        android:name="android.accessibilityservice"
        android:resource="@xml/accessibility_service_config" />
</service>

3. Add Permissions

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

4. Download Offline Language Pack

For best performance, download the Indonesian speech recognition model:

Settings β†’ System β†’ Languages β†’ Speech β†’ Offline speech recognition β†’ Indonesian

Usage #

Basic Setup #

import 'package:vui_plugin/vui_plugin.dart';

final vuiPlugin = VuiPlugin();

// Listen to voice commands
vuiPlugin.onVuiCommand.listen((command) {
  print('Intent: ${command.intent}');
  print('Slots: ${command.slots}');
  print('Raw text: ${command.rawText}');
});

// Set current screen for context-aware commands
await vuiPlugin.setCurrentScreen('beranda');

// Get available commands for current screen
final commands = await vuiPlugin.getAvailableCommands();

VuiCommand Structure #

class VuiCommand {
  final String intent;          // e.g., "SET_FIELD", "QUICK_SELL"
  final Map<String, String> slots;  // e.g., {"field_name": "harga_jual", "value": "5000"}
  final String rawText;         // Original speech text
  final double confidence;      // Recognition confidence (0.0 - 1.0)
}

Speech State Events #

The plugin emits SPEECH_STATE events for UI feedback:

State Description
LISTENING_START Microphone activated, ready for speech
PARTIAL_TEXT Live transcription update
LISTENING_END Speech input finished
COMMAND_RECOGNIZED Valid command detected
COMMAND_NOT_RECOGNIZED Speech heard but no matching command
RETRYING Auto-retrying after transient error
ERROR Recognition error (with error_code)

Supported Intents #

Intent Description Example Voice Command
SET_FIELD Fill a form field "harga jual 5000"
QUICK_SELL Quick sale action "jual indomie 3"
QUICK_BUY Quick stock addition "tambah stok indomie 10"
ADD_PRODUCT Navigate to add product "tambah produk"
SEARCH_PRODUCT Search for a product "cari indomie"
NAV_BACK Navigate back "kembali"
SHOW_HELP Show help overlay "bantuan"

Customization #

Adding Custom NLP Patterns #

Extend NlpEngine.kt to add domain-specific voice commands:

// In tryParseSetField(), add new field patterns:
val fieldPatterns = mapOf(
    "your_field" to Regex("""(?:your trigger words)\s+(.+)"""),
    // ... existing patterns
)

Adding New Screens #

Register new screen commands in getAvailableCommands():

"your_screen" -> listOf(
    "command pattern 1",
    "command pattern 2",
)

Requirements #

  • Android 8.0 (API 26) or higher
  • Flutter 3.3.0 or higher
  • Accessibility Service must be enabled by the user
  • Microphone permission required

License #

MIT License β€” see LICENSE for details.

1
likes
150
points
--
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for Voice User Interface (VUI) using Android Accessibility Service. Provides on-device speech recognition with rule-based NLP for Indonesian language, enabling voice-controlled navigation, form filling, and command execution.

Repository (GitHub)
View/report issues

Topics

#voice #accessibility #nlp #speech-recognition #indonesian

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on vui_plugin

Packages that implement vui_plugin