File size: 1,252 Bytes
aa7ea68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)