abdullahzunorain commited on
Commit
b35c19e
·
verified ·
1 Parent(s): a576cb5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -48
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 custom background and styling
92
- custom_css = """
93
- <style>
94
- body {
95
- background-color: #f4f4f4;
96
- font-family: Arial, sans-serif;
97
- }
98
- .container {
99
- background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
100
- border-radius: 12px;
101
- padding: 20px;
102
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
103
- max-width: 700px;
104
- margin: auto;
105
- }
106
- .chat-history {
107
- background-color: #ffffff;
108
- border-radius: 10px;
109
- padding: 15px;
110
- height: 300px;
111
- overflow-y: auto;
112
- box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
113
- }
114
- .user-message {
115
- color: #0084ff;
116
- font-weight: bold;
117
- margin-bottom: 5px;
118
- }
119
- .bot-message {
120
- color: #5a5a5a;
121
- margin-bottom: 10px;
122
- }
123
- .audio-output {
124
- margin-top: 15px;
125
- background-color: #d8f3dc;
126
- border-radius: 8px;
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.HTML("<div class='chat-history'></div>"), # Display chat history in a styled div
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