signlanguage / app.py
harshith1411's picture
Create app.py
aa7ea68 verified
raw
history blame
1.25 kB
from flask import Flask, request, jsonify
import cv2
import numpy as np
from sign_language_model import predict_sign_language
app = Flask(__name__)
@app.route('/')
def home():
return "Welcome to the Learning App for Deaf and Mute"
@app.route('/convert', methods=['POST'])
def convert_sign_to_text():
"""
Accepts an image of a sign language gesture and converts it to text.
"""
try:
file = request.files['image']
image = cv2.imdecode(np.fromstring(file.read(), np.uint8), cv2.IMREAD_COLOR)
text = predict_sign_language(image)
return jsonify({"text": text, "status": "success"}), 200
except Exception as e:
return jsonify({"error": str(e), "status": "failure"}), 500
@app.route('/learn', methods=['GET'])
def learning_module():
"""
Provides learning content for deaf and mute individuals.
"""
# Example learning content (can be extended)
content = {
"title": "Learn Sign Language",
"lessons": [
{"id": 1, "title": "Alphabet A-Z"},
{"id": 2, "title": "Common Words and Phrases"},
{"id": 3, "title": "Numbers 1-10"}
]
}
return jsonify(content), 200
if __name__ == '__main__':
app.run(debug=True)