Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,8 @@ import os
|
|
3 |
from gtts import gTTS
|
4 |
import gradio as gr
|
5 |
from groq import Groq
|
6 |
-
from datetime import datetime
|
|
|
7 |
|
8 |
# Load a smaller Whisper model for faster processing
|
9 |
try:
|
@@ -88,54 +89,49 @@ def chatbot(audio):
|
|
88 |
print(f"Error in chatbot function: {e}")
|
89 |
return "Sorry, there was an error processing your request.", None, chat_history
|
90 |
|
91 |
-
# CSS for
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
padding: 10px;
|
128 |
-
text-align: center;
|
129 |
-
}
|
130 |
-
</style>
|
131 |
-
"""
|
132 |
|
133 |
# Gradio interface for real-time interaction with chat history display
|
134 |
iface = gr.Interface(
|
135 |
fn=chatbot,
|
136 |
inputs=gr.Audio(type="filepath"),
|
137 |
outputs=[
|
138 |
-
gr.
|
139 |
gr.Audio(type="filepath", label="Response Audio"),
|
140 |
],
|
141 |
live=True,
|
@@ -144,9 +140,6 @@ iface = gr.Interface(
|
|
144 |
theme="default"
|
145 |
)
|
146 |
|
147 |
-
# Inject the custom CSS into the interface
|
148 |
-
iface.css = custom_css
|
149 |
-
|
150 |
# Launch the Gradio app
|
151 |
if __name__ == "__main__":
|
152 |
iface.launch()
|
@@ -161,8 +154,6 @@ if __name__ == "__main__":
|
|
161 |
|
162 |
|
163 |
|
164 |
-
|
165 |
-
|
166 |
# import whisper
|
167 |
# import os
|
168 |
# from gtts import gTTS
|
|
|
3 |
from gtts import gTTS
|
4 |
import gradio as gr
|
5 |
from groq import Groq
|
6 |
+
from datetime import datetime # Import datetime to handle timestamps
|
7 |
+
from IPython.display import HTML
|
8 |
|
9 |
# Load a smaller Whisper model for faster processing
|
10 |
try:
|
|
|
89 |
print(f"Error in chatbot function: {e}")
|
90 |
return "Sorry, there was an error processing your request.", None, chat_history
|
91 |
|
92 |
+
# Inject custom CSS for background and styling
|
93 |
+
def set_background():
|
94 |
+
return HTML('''
|
95 |
+
<style>
|
96 |
+
body {
|
97 |
+
background-image: url("https://raw.githubusercontent.com/username/repository/main/path/to/your-image.png");
|
98 |
+
background-size: cover;
|
99 |
+
background-position: center;
|
100 |
+
background-repeat: no-repeat;
|
101 |
+
color: white;
|
102 |
+
font-family: Arial, sans-serif;
|
103 |
+
}
|
104 |
+
.gradio-container {
|
105 |
+
background-color: rgba(0, 0, 0, 0.6);
|
106 |
+
padding: 20px;
|
107 |
+
border-radius: 8px;
|
108 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
109 |
+
}
|
110 |
+
h1, h2, p, .gradio-label {
|
111 |
+
color: #FFD700; /* Gold color for labels and titles */
|
112 |
+
}
|
113 |
+
.gradio-button {
|
114 |
+
background-color: #FFD700;
|
115 |
+
color: black;
|
116 |
+
border-radius: 4px;
|
117 |
+
font-weight: bold;
|
118 |
+
}
|
119 |
+
.gradio-input {
|
120 |
+
background-color: rgba(255, 255, 255, 0.9);
|
121 |
+
border-radius: 4px;
|
122 |
+
}
|
123 |
+
</style>
|
124 |
+
''')
|
125 |
+
|
126 |
+
# Display custom background styling
|
127 |
+
set_background()
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
# Gradio interface for real-time interaction with chat history display
|
130 |
iface = gr.Interface(
|
131 |
fn=chatbot,
|
132 |
inputs=gr.Audio(type="filepath"),
|
133 |
outputs=[
|
134 |
+
gr.Textbox(label="Chat History"), # Display chat history
|
135 |
gr.Audio(type="filepath", label="Response Audio"),
|
136 |
],
|
137 |
live=True,
|
|
|
140 |
theme="default"
|
141 |
)
|
142 |
|
|
|
|
|
|
|
143 |
# Launch the Gradio app
|
144 |
if __name__ == "__main__":
|
145 |
iface.launch()
|
|
|
154 |
|
155 |
|
156 |
|
|
|
|
|
157 |
# import whisper
|
158 |
# import os
|
159 |
# from gtts import gTTS
|