This app uses your MacBook's camera to detect American Sign Language (ASL) letters in real-time using OpenCV, MediaPipe, and a pre-trained Keras model. It overlays the predicted letter on the video feed and can optionally convert recognized text to speech.
- Real-time webcam video with hand detection
- ASL letter prediction (A–Z) using a trained model
- Overlay of predicted letter and sentence on video
- Optional data collection mode for new signs
- Support for both hands (if detected)
- Text-to-speech output (pyttsx3)
- macOS (tested on Apple Silicon and Intel MacBooks)
- Python 3.8+
-
Clone this repository (or copy the code files):
git clone <your-repo-url> cd sign_language
-
Install dependencies:
pip install opencv-python mediapipe tensorflow pyttsx3 numpy
- If you have issues with
pyttsx3on macOS, try:pip install pyobjc
- If you have issues with
-
Prepare your model:
- Place your trained Keras model as
asl_model.h5in the project directory. - The model should take a 63-element input (21 hand landmarks × 3 coordinates) and output 26 classes (A–Z).
- You can collect data using the app's data collection mode and train your own model with Keras.
- Place your trained Keras model as
python asl_realtime.py- Press
qto quit. - Press
cto toggle data collection mode (saves hand landmark data tocollected_data.csv). - The label for data collection is hardcoded as 'A' (edit in the code as needed).
- The app uses the default webcam (index 0). If you have multiple cameras, you may need to change the index in the code.
- For best results, use a well-lit environment and keep your hand within the camera frame.
- The app overlays the predicted letter and the running sentence on the video feed.
- Text-to-speech will read out the sentence every few seconds.
- If you get errors related to the webcam, ensure camera permissions are enabled for Terminal/Python in System Preferences > Security & Privacy > Privacy > Camera.
- If you get errors with
pyttsx3, try installingpyobjcas above. - If you see
asl_model.h5not found, ensure your model is in the correct location.
MIT