@rajeev02/edge-ai 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +170 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # @rajeev02/edge-ai
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@rajeev02/edge-ai.svg)](https://www.npmjs.com/package/@rajeev02/edge-ai)
4
+ [![license](https://img.shields.io/npm/l/@rajeev02/edge-ai.svg)](https://github.com/Rajeev02/rajeev-sdk/blob/main/LICENSE)
5
+
6
+ **On-device ML toolkit** with Indian ID card OCR (Aadhaar/PAN/DL), model pipeline (TFLite/CoreML/ONNX/WASM), and voice AI in 11 Indian languages.
7
+
8
+ Part of [Rajeev SDK](https://github.com/Rajeev02/rajeev-sdk) — cross-platform infrastructure libraries for building apps that work everywhere.
9
+
10
+ ## Why use this?
11
+
12
+ - **Indian ID OCR** — Extract and validate Aadhaar, PAN, Driving License from scanned text. Verhoeff checksum for Aadhaar.
13
+ - **ML model pipeline** — Register, load, and run TFLite / CoreML / ONNX / WASM models with a unified API
14
+ - **Voice AI** — Parse voice commands in 11 Indian languages (Hindi, Tamil, Bengali, Telugu, Marathi, Gujarati, Kannada, Malayalam, Odia, Punjabi, English)
15
+ - **Intent detection** — "pay 500 to Rajeev" → `{ intent: "pay", entities: { amount: "500", recipient: "Rajeev" } }`
16
+ - **GPU acceleration** — Optional GPU backend for TFLite and CoreML models
17
+ - **Privacy-first** — All processing happens on device. No data sent to cloud servers.
18
+
19
+ ## ⚠️ Important: ML Runtimes & OCR Engine Required
20
+
21
+ This library provides **ML pipeline management, text parsing utilities, and voice intent matching**. It does **NOT** include ML models, OCR engines, or speech recognition.
22
+
23
+ | What the library does | What YOU must provide |
24
+ | ------------------------------------------------- | --------------------------------------------------- |
25
+ | Parse OCR text to extract PAN/Aadhaar/DL numbers | OCR engine to convert images → text first |
26
+ | Validate Aadhaar (Verhoeff checksum), PAN format | Nothing — works standalone |
27
+ | Model lifecycle management (register/load/unload) | TFLite, CoreML, or ONNX runtime + model files |
28
+ | Rule-based voice intent parsing (11 languages) | Speech-to-text engine to convert audio → text first |
29
+
30
+ **OCR functions** (`extractPanNumber`, `extractAadhaarNumber`, `detectDocumentType`) accept **pre-extracted text strings** — you must first convert images to text using an OCR engine:
31
+
32
+ | Platform | Recommended OCR engine |
33
+ | -------------- | ---------------------------------------------------------------------------------------------- |
34
+ | iOS | [Apple Vision Framework](https://developer.apple.com/documentation/vision) |
35
+ | Android | [Google ML Kit Text Recognition](https://developers.google.com/ml-kit/vision/text-recognition) |
36
+ | Cross-platform | [Tesseract.js](https://tesseract.projectnaptha.com/) (web/WASM) |
37
+
38
+ **ML pipeline** manages model state (register → load → ready → unload) but actual inference must be implemented via native ML runtimes on each platform.
39
+
40
+ **Voice AI** parses text commands using regex-based intent detection — it does not record or transcribe audio. Feed it text from a speech-to-text engine like [Google Speech-to-Text](https://cloud.google.com/speech-to-text) or [Whisper](https://openai.com/research/whisper).
41
+
42
+ ## Platform Support
43
+
44
+ | Platform | Engine | Status |
45
+ | ---------- | ---------- | ------ |
46
+ | iOS 16+ | TypeScript | ✅ |
47
+ | Android 7+ | TypeScript | ✅ |
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ npm install @rajeev02/edge-ai
53
+ ```
54
+
55
+ ### Peer Dependencies
56
+
57
+ - `react` >= 18.3.0
58
+ - `react-native` >= 0.84.0 _(optional)_
59
+
60
+ ## Quick Start
61
+
62
+ ### Indian ID OCR
63
+
64
+ ```typescript
65
+ import {
66
+ detectDocumentType,
67
+ extractPanNumber,
68
+ extractAadhaarNumber,
69
+ validatePan,
70
+ validateAadhaar,
71
+ getScanningTips,
72
+ } from "@rajeev02/edge-ai";
73
+
74
+ // Detect document type from OCR text
75
+ const docType = detectDocumentType("Income Tax Department PAN ABCPE1234F");
76
+ // → "pan"
77
+
78
+ // Extract PAN
79
+ const pan = extractPanNumber("Name: Rajeev PAN: ABCPE1234F DOB: 01/01/1990");
80
+ // → "ABCPE1234F"
81
+
82
+ // Extract masked Aadhaar
83
+ const aadhaar = extractAadhaarNumber("Aadhaar: 1234 5678 9012");
84
+ // → "XXXX XXXX 9012"
85
+
86
+ // Validate
87
+ validatePan("ABCPE1234F"); // → true
88
+ validateAadhaar("123456789012"); // → true (Verhoeff checksum)
89
+
90
+ // Get scanning tips for users
91
+ getScanningTips("aadhaar");
92
+ // → ["Place the card on a flat surface", "Ensure all four corners are visible", ...]
93
+ ```
94
+
95
+ ### ML Model Pipeline
96
+
97
+ ```typescript
98
+ import { ModelManager } from "@rajeev02/edge-ai";
99
+
100
+ const mm = new ModelManager();
101
+
102
+ // Register a model
103
+ mm.register({
104
+ id: "face_detect",
105
+ name: "Face Detection",
106
+ modelPath: "models/face.tflite",
107
+ backend: "tflite",
108
+ useGpu: true,
109
+ });
110
+
111
+ // Load into memory
112
+ await mm.load("face_detect");
113
+ console.log(mm.isReady("face_detect")); // → true
114
+
115
+ // Get model info
116
+ const info = mm.getModelInfo("face_detect");
117
+ // → { id, name, status: "ready", backend, sizeBytes, loadTimeMs }
118
+
119
+ // Unload when done
120
+ mm.unload("face_detect");
121
+ ```
122
+
123
+ ### Voice AI
124
+
125
+ ```typescript
126
+ import { parseVoiceIntent, SUPPORTED_VOICE_LANGUAGES } from "@rajeev02/edge-ai";
127
+
128
+ // Parse natural language commands
129
+ const intent = parseVoiceIntent("pay 500 to Rajeev", "en");
130
+ // → { intent: "pay", confidence: 0.95, entities: { amount: "500", recipient: "Rajeev" }, language: "en" }
131
+
132
+ const hindiIntent = parseVoiceIntent("Rajeev ko 500 bhejo", "hi");
133
+ // → { intent: "pay", confidence: 0.92, entities: { amount: "500", recipient: "Rajeev" }, language: "hi" }
134
+
135
+ // 11 supported languages
136
+ console.log(SUPPORTED_VOICE_LANGUAGES);
137
+ // → ["en", "hi", "ta", "bn", "te", "mr", "gu", "kn", "ml", "or", "pa"]
138
+ ```
139
+
140
+ ## Supported Document Types
141
+
142
+ | Type | Detection Keywords | Extraction |
143
+ | --------------- | ------------------------------- | -------------------------- |
144
+ | Aadhaar | "UIDAI", "Aadhaar" | Number (masked), name, DOB |
145
+ | PAN | "Income Tax", "PAN" | PAN number, name, DOB |
146
+ | Driving License | "Driving", "License", "DL" | DL number, name, validity |
147
+ | Voter ID | "Election Commission" | Voter ID, name |
148
+ | Passport | "Passport", "Republic of India" | Passport number, name |
149
+
150
+ ## API Reference
151
+
152
+ | Export | Type | Description |
153
+ | --------------------------- | ---------- | ----------------------------------- |
154
+ | `detectDocumentType()` | `function` | Detect Indian ID type from OCR text |
155
+ | `extractAadhaarNumber()` | `function` | Extract masked Aadhaar number |
156
+ | `extractPanNumber()` | `function` | Extract PAN number |
157
+ | `validatePan()` | `function` | Validate PAN format |
158
+ | `validateAadhaar()` | `function` | Validate Aadhaar (Verhoeff) |
159
+ | `getScanningTips()` | `function` | Get user-facing scanning tips |
160
+ | `ModelManager` | `class` | ML model lifecycle management |
161
+ | `parseVoiceIntent()` | `function` | Parse voice commands to intents |
162
+ | `SUPPORTED_VOICE_LANGUAGES` | `string[]` | List of supported languages |
163
+
164
+ ## Full Documentation
165
+
166
+ 📖 [Complete API docs with model config and voice AI](https://github.com/Rajeev02/rajeev-sdk/blob/main/docs/usage/EDGE-AI.md)
167
+
168
+ ## License
169
+
170
+ MIT © 2026 [Rajeev Kumar Joshi](https://rajeev02.github.io)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rajeev02/edge-ai",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Edge AI / On-Device ML Toolkit — OCR, face detection, voice commands, document scanner, smart crop",
5
5
  "main": "lib/index.js",
6
6
  "author": "Rajeev Kumar Joshi <rajeevjoshi91@gmail.com> (https://rajeev02.github.io)",