File size: 640 Bytes
7925c8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# app.py
from flask import Flask, render_template, request, jsonify
from chatbot_engine import ChatBot
from stt import listen_and_transcribe

app = Flask(__name__)
bot = ChatBot()

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/ask", methods=["POST"])
def ask():
    data = request.get_json()
    user_input = data.get("message", "")
    reply = bot.ask(user_input)
    return jsonify({"reply": reply})

@app.route("/listen", methods=["GET"])
def listen():
    text = listen_and_transcribe()
    return jsonify({"text": text})

if __name__ == "__main__":
    app.run(debug=True)