Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,51 @@ from voice_ai import voice_ai
|
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
|
|
8 |
@app.route("/")
|
9 |
def index():
|
10 |
return render_template("index.html")
|
11 |
|
|
|
12 |
@app.route("/chatbot")
|
13 |
def chatbot_page():
|
14 |
return render_template("chatbot.html")
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
app.run(debug=True)
|
|
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
8 |
+
# Flask Route for Home
|
9 |
@app.route("/")
|
10 |
def index():
|
11 |
return render_template("index.html")
|
12 |
|
13 |
+
# Flask Route for Chatbot
|
14 |
@app.route("/chatbot")
|
15 |
def chatbot_page():
|
16 |
return render_template("chatbot.html")
|
17 |
|
18 |
+
# Define Gradio Interfaces
|
19 |
+
def chatbot_interface(input_text):
|
20 |
+
return chatbot(input_text) # Replace with your chatbot logic
|
21 |
+
|
22 |
+
def voice_ai_interface(audio_input):
|
23 |
+
return voice_ai(audio_input) # Replace with your voice AI logic
|
24 |
+
|
25 |
+
# Gradio App
|
26 |
+
chatbot_gradio = gr.Interface(
|
27 |
+
fn=chatbot_interface,
|
28 |
+
inputs="text",
|
29 |
+
outputs="text",
|
30 |
+
title="Chatbot AI",
|
31 |
+
description="Ask me anything!"
|
32 |
+
)
|
33 |
+
|
34 |
+
voice_ai_gradio = gr.Interface(
|
35 |
+
fn=voice_ai_interface,
|
36 |
+
inputs="audio",
|
37 |
+
outputs="text",
|
38 |
+
title="Voice AI",
|
39 |
+
description="Speak and I'll transcribe."
|
40 |
+
)
|
41 |
+
|
42 |
+
# Enable Gradio Public Links
|
43 |
+
def start_gradio():
|
44 |
+
chatbot_gradio.launch(share=True, inbrowser=True)
|
45 |
+
voice_ai_gradio.launch(share=True, inbrowser=True)
|
46 |
+
|
47 |
+
# Main Flask Application
|
48 |
if __name__ == "__main__":
|
49 |
+
import threading
|
50 |
+
|
51 |
+
# Run Gradio in a separate thread
|
52 |
+
threading.Thread(target=start_gradio).start()
|
53 |
+
|
54 |
+
# Start Flask Server
|
55 |
app.run(debug=True)
|