Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,41 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
return f"You said: {text}"
|
6 |
|
7 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
gr.Interface(
|
9 |
-
fn=
|
10 |
-
inputs="
|
11 |
-
outputs="
|
12 |
-
|
13 |
-
description="Ask anything related to hotel booking",
|
14 |
).launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from flask import Flask, render_template
|
3 |
|
4 |
+
# Initialize Flask app
|
5 |
+
app = Flask(__name__)
|
|
|
6 |
|
7 |
+
# Chatbot Functionality
|
8 |
+
def chatbot_response(input_text):
|
9 |
+
# Example response using OpenAI
|
10 |
+
response = "You said: " + input_text
|
11 |
+
return response
|
12 |
+
|
13 |
+
# Voice AI Functionality
|
14 |
+
def voice_transcription(audio):
|
15 |
+
# Example voice transcription
|
16 |
+
transcription = audio
|
17 |
+
return transcription
|
18 |
+
|
19 |
+
# Define Chatbot UI
|
20 |
+
def chatbot_ui(input_text):
|
21 |
+
return chatbot_response(input_text)
|
22 |
+
|
23 |
+
# Define Voice Chat UI
|
24 |
+
def voice_ui(audio):
|
25 |
+
return voice_transcription(audio)
|
26 |
+
|
27 |
+
# Web interface for chatbot
|
28 |
+
gr.Interface(
|
29 |
+
fn=chatbot_ui,
|
30 |
+
inputs=gr.inputs.Textbox(label="Type your message"),
|
31 |
+
outputs=gr.outputs.Textbox(label="Response"),
|
32 |
+
live=True
|
33 |
+
).launch()
|
34 |
+
|
35 |
+
# Web interface for voice interaction
|
36 |
gr.Interface(
|
37 |
+
fn=voice_ui,
|
38 |
+
inputs=gr.inputs.Audio(label="Speak your message"),
|
39 |
+
outputs=gr.outputs.Textbox(label="Transcription"),
|
40 |
+
live=True
|
|
|
41 |
).launch()
|