CoolFace
Apppublic

Piyush23890/Sign_Language_Decoder

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes
App README

🀟 SignBridge β€” Indian Sign Language Smart Communication System

Real-time ISL gesture β†’ Text β†’ Speech, with live English ↔ Hindi translation. Single-click desktop app β€” no Python required for end users.

System Active Python Flask MediaPipe License


Table of Contents

  1. 1.What is SignBridge?
  2. 2.Features
  3. 3.System Architecture
  4. 4.Project Structure
  5. 5.Quick Start (End Users)
  6. 6.Developer Setup
  7. 7.Data Collection
  8. 8.Training Models
  9. 9.Running the App
  10. 10.Building the .exe
  11. 11.Controls & Keyboard Shortcuts
  12. 12.Tech Stack
  13. 13.Troubleshooting

What is SignBridge?

SignBridge converts Indian Sign Language (ISL) hand gestures captured via a standard webcam into readable English text and spoken audio β€” in real time.

It bridges the communication gap between India's ~6.3 million hearing-impaired ISL users and the general public, requiring no specialist hardware beyond a laptop camera.


Features

FeatureDetail
Static sign recognitionA–Z alphabet via Random Forest (126 MediaPipe landmark features)
Dynamic word recognition"Hello", "Thank You" via LSTM β†’ ONNX (30-frame sequences)
Motion-based switchingAutomatically picks static or dynamic mode β€” no buttons needed
Smart sentence builderAuto-spacing, backspace, clear β€” builds natural sentences
Live translationEnglish ↔ Hindi via deep-translator (Google)
Text-to-SpeechBrowser Web Speech API (no server round-trip)
Speech-to-TextBrowser Web Speech API β†’ optional Hindi translation
WebSocket UIReal-time updates via Flask-SocketIO (no page refreshes)
Single-click .exePyInstaller bundle for Windows β€” no Python needed
Git LFS readyLarge model files tracked correctly

System Architecture

Webcam Frame (OpenCV)
        β”‚
        β–Ό
MediaPipe Hands
  21 landmarks Γ— 3 coords Γ— 2 hands = 126 features
        β”‚
        β–Ό
  Motion Score  =  β€–keypoints_t βˆ’ keypoints_{t-1}β€–
        β”‚
   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ motion < 0.10           β”‚ motion β‰₯ 0.10
   β–Ό                         β–Ό
Random Forest            ONNX LSTM
(static A–Z)         (dynamic words)
   β”‚                         β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β–Ό
     SentenceBuilder
  (auto-space Β· backspace Β· clear)
              β”‚
              β–Ό
    Deep-Translator  (EN ↔ HI)
              β”‚
        β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
        β–Ό           β–Ό
  WebSocket      Video Feed
  (SocketIO)     (MJPEG stream)
        β”‚
        β–Ό
   Browser UI
  (HTML + JS)
        β”‚
   Web Speech API
  (TTS + STT)

Project Structure

SignBridge/
β”‚
β”œβ”€β”€ app.py                      ← Main Flask application (run this)
β”œβ”€β”€ sentence_builder.py         ← SentenceBuilder class (also importable)
β”‚
β”œβ”€β”€ templates/
β”‚   └── index.html              ← UI template (Jinja2)
β”‚
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ style.css               ← Dark glassmorphism styles
β”‚   └── script.js               ← WebSocket + STT/TTS + clipboard JS
β”‚
β”œβ”€β”€ dataset/                    ← Static landmark CSVs (created by collection)
β”‚   β”œβ”€β”€ A/data.csv
β”‚   β”œβ”€β”€ B/data.csv
β”‚   └── ...Z/data.csv
β”‚
β”œβ”€β”€ dynamic_dataset/            ← Dynamic .npy sequences
β”‚   β”œβ”€β”€ hello/
β”‚   β”‚   β”œβ”€β”€ 0.npy ... N.npy
β”‚   └── thank_you/
β”‚       β”œβ”€β”€ 0.npy ... N.npy
β”‚
β”œβ”€β”€ isl_alphabet_model.pkl      ← Trained static RF model  (Git LFS)
β”œβ”€β”€ dynamic_sign_model.h5       ← Trained LSTM model       (Git LFS)
β”œβ”€β”€ dynamic_sign_model.onnx     ← ONNX version for runtime (Git LFS)
β”‚
β”œβ”€β”€ hand_landmarks_dataset.py   ← Collect static data
β”œβ”€β”€ collect_dynamic_data.py     ← Collect dynamic data
β”œβ”€β”€ merge_dataset.py            ← Merge per-letter CSVs β†’ final_dataset.csv
β”œβ”€β”€ train_model.py              ← Train Random Forest
β”œβ”€β”€ train_dynamic_model.py      ← Train LSTM
β”œβ”€β”€ convert_to_onnx.py          ← Convert .h5 β†’ .onnx
β”œβ”€β”€ run_setup_wizard.py         ← All-in-one first-time setup
β”œβ”€β”€ live_predict.py             ← Standalone webcam prediction demo
β”‚
β”œβ”€β”€ test_sentence_builder.py    ← Unit tests
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ SignBridge.spec             ← PyInstaller build spec
β”œβ”€β”€ .gitignore
└── .gitattributes              ← Git LFS config

Quick Start (End Users)

  1. 1.Download SignBridge.exe from the dist/ folder (or the GitHub Release).
  2. 2.Double-click SignBridge.exe.
  3. 3.Your browser opens automatically at http://127.0.0.1:5000.
  4. 4.Show your hand to the webcam and start signing βœ‹.
No Python, no installation required.

Developer Setup

1 β€” Clone the repository

bash
git lfs install
git clone https://github.com/HetviPandav123/sign-language-smart-communication.git
cd sign-language-smart-communication
git lfs pull        # download model files tracked via LFS

2 β€” Create a virtual environment

bash
python -m venv venv

# Windows
venv\Scripts\activate

# Linux / macOS
source venv/bin/activate

3 β€” Install dependencies

bash
pip install -r requirements.txt
GPU users: Replace tensorflow with tensorflow-gpu in requirements.txt CPU-only machines: Use tensorflow-cpu instead

Data Collection

Option A β€” Automated wizard (recommended for first-time setup)

bash
python run_setup_wizard.py

The wizard guides you through:

  • β€”Recording 50 samples per letter (A–Z) with on-screen prompts
  • β€”Recording 30 gesture sequences each for "Hello" and "Thank You"
  • β€”Training both models automatically after collection

Option B β€” Manual collection

Static signs (A–Z):

bash
# Collect 200 samples for letter A
python hand_landmarks_dataset.py --sign A --samples 200

# Repeat for B through Z
python hand_landmarks_dataset.py --sign B --samples 200
# ...

Dynamic gestures:

bash
python collect_dynamic_data.py --action hello     --samples 200
python collect_dynamic_data.py --action thank_you --samples 200
Tips for good data: - Use consistent lighting (avoid backlighting) - Vary hand distance (30–80 cm from camera) - Slightly vary the angle between samples for robustness

Training Models

Train static Random Forest model

bash
python train_model.py

Output: isl_alphabet_model.pkl + label_map.pkl

Train dynamic LSTM model

bash
python train_dynamic_model.py

Output: dynamic_sign_model.h5

Convert LSTM β†’ ONNX (required for app.py)

bash
python convert_to_onnx.py

Output: dynamic_sign_model.onnx

Merge static CSVs (optional β€” for inspection)

bash
python merge_dataset.py

Output: final_dataset.csv


Running the App

bash
python app.py

The browser opens automatically at http://127.0.0.1:5000.

If the browser doesn't open, navigate there manually.

Building the .exe

Requires both models to be trained and present first.

bash
pip install pyinstaller
pyinstaller SignBridge.spec

The executable is written to dist/SignBridge.exe.

The spec file excludes TensorFlow from the bundle (it is mocked at runtime) which keeps the .exe size manageable. Only onnxruntime is bundled for inference.

Controls & Keyboard Shortcuts

In-app buttons

ButtonAction
πŸ”Š SpeakRead the sentence aloud (Web Speech API)
⌫ BackspaceDelete last letter or word
βœ– ClearReset the entire sentence
🎀 Tap to SpeakToggle Speech-to-Text
πŸ“‹ CopyCopy sentence / STT text to clipboard
Language selectorSwitch display between English and Hindi

Keyboard shortcuts

KeyAction
EnterSpeak the current sentence
BackspaceDelete last token
CClear sentence

Tech Stack

CategoryTechnologyPurpose
LanguagePython 3.10+Core backend
Computer VisionOpenCV 4.xWebcam capture, MJPEG streaming
Hand TrackingMediaPipe Hands21-point landmark detection per hand
Static MLScikit-learn RandomForestLetter classification A–Z
Dynamic DLTensorFlow/Keras LSTMWord-level gesture sequence recognition
InferenceONNX RuntimeFast, TF-free inference in production
Web BackendFlask + Flask-SocketIOHTTP routes + WebSocket push updates
FrontendHTML5 / CSS3 / Vanilla JSUI, camera feed display
TTS / STTWeb Speech API (browser)No server latency
Translationdeep-translator (Google)EN ↔ HI live translation
PackagingPyInstallerSingle .exe for Windows distribution
Large FilesGit LFS.pkl / .h5 / .onnx / .exe version control

Troubleshooting

"Paging file too small" on Windows

Caused by Flask debug mode + memory-mapped files. Fix: app.py already sets debug=False. If you still see this, restart your PC to clear the paging file.

Webcam not detected

bash
# Check which index works (try 0, 1, 2)
python -c "import cv2; cap=cv2.VideoCapture(0); print(cap.isOpened())"

Change cv2.VideoCapture(0) in app.py to the correct index.

MediaPipe import error in .exe

The SignBridge.spec already includes collect_all('mediapipe') and sys._MEIPASS path resolution. Rebuild with the provided spec β€” do not use pyinstaller app.py directly.

Static sign flickering

Each letter is locked after STATIC_FRAMES=5 stable frames and won't repeat until the hand moves away. Increase STATIC_FRAMES in app.py for stricter locking.

Poor recognition accuracy

  • β€”Collect more samples per sign (200+ recommended)
  • β€”Vary lighting conditions during collection
  • β€”Ensure both hands are visible for two-handed signs
  • β€”Re-train with the new data

Translation not working

Requires an internet connection. deep-translator uses Google Translate API. If offline, the raw English sentence is shown as fallback.


Author

Hetvi Pandav BE – Artificial Intelligence & Machine Learning


⭐ If SignBridge helped you, star the repo!