-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp3.py
More file actions
40 lines (34 loc) ยท 1012 Bytes
/
Copy pathapp3.py
File metadata and controls
40 lines (34 loc) ยท 1012 Bytes
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
from flask import Flask, jsonify, render_template
import threading
from slot_manager import process_text_command, slots
from tts import speak
import speech_recognition as sr
app = Flask(__name__)
def listen_command():
r = sr.Recognizer()
with sr.Microphone() as source:
print("๐ค ์์ฑ ์
๋ ฅ ๋๊ธฐ ์ค...")
audio = r.listen(source)
try:
return r.recognize_google(audio, language='ko-KR')
except:
return "์ธ์ ์คํจ"
@app.route("/")
def index():
return render_template("index.html")
@app.route("/listen")
def listen():
def worker():
text = listen_command()
print(f"๋ฐ์ ๋ช
๋ น์ด: {text}")
if text == "์ธ์ ์คํจ":
speak("์์ฑ ์ธ์ ์คํจ")
return
process_text_command(text)
threading.Thread(target=worker).start()
return jsonify({"status": "listening"})
@app.route("/slots")
def get_slots():
return jsonify(slots)
if __name__ == "__main__":
app.run(debug=True)