|
| 1 | +# LingoLens 📸 |
| 2 | + |
| 3 | +**LingoLens** is a powerful **AI Visual Translator** built for the **Lingo.dev Community Sprint**. |
| 4 | + |
| 5 | +It upgrades standard OCR with **Intelligent Script Detection** and **Lingo.dev's AI Language Inference**. Wrapped in a stunning **Glassmorphism UI**, it allows users to upload images of text (receipts, signs, documents) and automatically detects the language script and translation context in real-time. |
| 6 | + |
| 7 | +## 🎥 Demo & Testing |
| 8 | +We have provided resources to help you test the application quickly: |
| 9 | + |
| 10 | +### 1. Watch the Demo |
| 11 | +> **[Click here to watch the Demo Video on YouTube 📺](https://youtu.be/ZJFpRb-49eE)** |
| 12 | +
|
| 13 | +### 2. Test with Sample Data |
| 14 | +I have included a sample receipt image in this repository for you to test with: |
| 15 | +* **File:** [`test.png`](./test.png) |
| 16 | +* **Usage:** Drag and drop this image into the app to see the Auto-Detection and Translation in action immediately. |
| 17 | + |
| 18 | +## 🚀 Lingo.dev Features Highlighted |
| 19 | +This project demonstrates key capabilities of the Lingo.dev ecosystem: |
| 20 | +1. **AI Language Inference:** Uses the `sourceLocale: null` feature of the **Lingo.dev SDK** to automatically identify the source language from the text context. |
| 21 | +2. **Smart Script Detection:** Implements **Tesseract OSD** (Orientation & Script Detection) to dynamically load the correct OCR alphabet (e.g., Japanese vs. Latin) before reading. |
| 22 | +3. **Real-time Localization:** Uses `lingo.localizeText` to provide accurate, context-aware translations for dynamic user content. |
| 23 | +4. **Secure Backend Proxy:** Implements a robust Node.js/Express bridge (`server.js`) to handle API authentication securely. |
| 24 | + |
| 25 | +## 🛠️ Setup Instructions |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | +* Node.js (v18 or higher) |
| 29 | +* A Lingo.dev API Key |
| 30 | + |
| 31 | +### 1. Installation |
| 32 | +Navigate to the project directory and install dependencies: |
| 33 | +```bash |
| 34 | +cd community/Lingo-lens |
| 35 | +npm install |
| 36 | +``` |
| 37 | + |
| 38 | +### 2. Configuration |
| 39 | +Create a .env file in the root of the Lingo-lens directory and add your API key: |
| 40 | +```bash |
| 41 | +LINGO_API_KEY=link_your_actual_api_key_here |
| 42 | +``` |
| 43 | + |
| 44 | +### 3. Running the App |
| 45 | + |
| 46 | +This application requires **both the backend server** (to communicate with Lingo.dev) and the **frontend client** (React) to run simultaneously. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +### Terminal 1 — Backend Server |
| 51 | + |
| 52 | +```bash |
| 53 | +node server.js |
| 54 | +``` |
| 55 | + |
| 56 | +You should see: `✅ Proxy Server running on http://localhost:3001` |
| 57 | + |
| 58 | + |
| 59 | +### Terminal 2 — Frontend Client |
| 60 | + |
| 61 | +```bash |
| 62 | +npm run dev |
| 63 | +``` |
| 64 | + |
| 65 | +Open the URL shown in the terminal: `(usually: http://localhost:5173)` |
| 66 | + |
| 67 | +## 📖 How It Works |
| 68 | + |
| 69 | +1. **Upload & Detect** User uploads an image. The app first runs **Tesseract OSD** to detect the script (e.g., "Han" for Chinese, "Latin" for English). |
| 70 | + |
| 71 | +2. **Extract (OCR)** Based on the script, the app loads the optimized OCR model (e.g., `chi_sim` or `eng`) and extracts the raw text from the image. |
| 72 | + |
| 73 | +3. **Inference** The frontend sends the text to the server with `sourceLang: 'auto'`. |
| 74 | + |
| 75 | +4. **Translate** The **Lingo.dev SDK** analyzes the text content, infers the source language, and generates a context-aware translation. |
| 76 | + |
| 77 | +5. **Result** The original text and the translation appear instantly on the animated Glassmorphism interface. |
| 78 | + |
| 79 | + |
0 commit comments