File size: 1,608 Bytes
aa7ea68
8527aef
aa7ea68
 
 
 
 
8527aef
aa7ea68
 
 
 
 
 
 
 
 
 
 
8527aef
 
 
 
aa7ea68
8527aef
aa7ea68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4f7121d
8527aef
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
43
44
45
46
47
48
from flask import Flask, request, jsonify
from flask_cors import CORS
import cv2
import numpy as np
from sign_language_model import predict_sign_language

app = Flask(__name__)
CORS(app)  # Allow cross-origin requests for Hugging Face or other external integrations

@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:
        # Check if an image file is provided in the request
        if 'image' not in request.files:
            return jsonify({"error": "No image file provided", "status": "failure"}), 400

        file = request.files['image']
        image = cv2.imdecode(np.frombuffer(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(host="0.0.0.0", port=5000, debug=True, use_reloader=False)