ar08 commited on
Commit
b598ccb
·
verified ·
1 Parent(s): 99f8018

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -24
app.py CHANGED
@@ -105,20 +105,84 @@ def transcribe_and_chat(audio):
105
 
106
  def create_demo():
107
  with gr.Blocks(css="""
108
- #audio-input {border: 2px solid #ffb703; padding: 10px;}
109
- #chat-output {background-color: #023047; color: #ffffff;}
110
- #audio-output {border: 2px solid #8ecae6;}
111
- #clear-button {background-color: #fb8500; color: white;}
112
- #voice-volume {background-color: #219ebc;}
113
- button {font-size: 16px;}
114
- audio {background-color: #ffb703; border-radius: 10px;}
115
- footer {display: none;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  """) as demo:
117
  gr.Markdown(
118
  """
119
- <div style='text-align:center; color:#023047; font-size: 28px; font-weight: bold;'>🗣️ AI Voice Assistant</div>
120
- <p style='text-align:center; color:#8ecae6; font-size: 18px;'>Talk to your personal AI! Record your voice, and get a response in both text and audio.</p>
121
- <p style='text-align:center; color:#8ecae6;'>Powered by advanced AI models for real-time interaction.</p>
122
  """,
123
  elem_id="header"
124
  )
@@ -193,22 +257,13 @@ def create_demo():
193
  });
194
 
195
  document.addEventListener('gradioUpdated', function(event) {
196
- setTimeout(playAssistantAudio, 100);
197
- });
198
-
199
- // Prevent audio from stopping when switching tabs
200
- document.addEventListener("visibilitychange", function() {
201
- var audioElements = document.querySelectorAll('audio');
202
- audioElements.forEach(function(audio) {
203
- audio.play();
204
- });
205
  });
206
  }
207
  """)
208
 
209
  return demo
210
 
211
- # Launch the Gradio app
212
- if __name__ == "__main__":
213
- demo = create_demo()
214
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
105
 
106
  def create_demo():
107
  with gr.Blocks(css="""
108
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
109
+
110
+ body { font-family: 'Poppins', sans-serif; }
111
+
112
+ #audio-input, #voice-volume {
113
+ border: 2px solid #ffb703;
114
+ padding: 10px;
115
+ box-shadow: 0px 0px 15px #ffb703;
116
+ }
117
+
118
+ #chat-output {
119
+ background-color: #023047;
120
+ color: #ffffff;
121
+ border-radius: 10px;
122
+ box-shadow: 0px 0px 15px #8ecae6;
123
+ }
124
+
125
+ #audio-output {
126
+ border: 2px solid #8ecae6;
127
+ box-shadow: 0px 0px 15px #8ecae6;
128
+ border-radius: 10px;
129
+ }
130
+
131
+ #clear-button {
132
+ background-color: #fb8500;
133
+ color: white;
134
+ font-size: 16px;
135
+ border-radius: 5px;
136
+ box-shadow: 0px 0px 15px #fb8500;
137
+ }
138
+
139
+ #voice-volume {
140
+ background-color: #219ebc;
141
+ border-radius: 5px;
142
+ box-shadow: 0px 0px 15px #219ebc;
143
+ }
144
+
145
+ button {
146
+ font-size: 16px;
147
+ font-family: 'Poppins', sans-serif;
148
+ padding: 10px;
149
+ }
150
+
151
+ audio {
152
+ background-color: #ffb703;
153
+ border-radius: 10px;
154
+ }
155
+
156
+ h1 {
157
+ text-align: center;
158
+ color: #023047;
159
+ font-size: 28px;
160
+ font-weight: bold;
161
+ text-shadow: 0px 0px 15px #023047;
162
+ }
163
+
164
+ p {
165
+ text-align: center;
166
+ color: #8ecae6;
167
+ font-size: 18px;
168
+ }
169
+
170
+ @media (max-width: 768px) {
171
+ #audio-input, #audio-output, #voice-volume, #chat-output {
172
+ font-size: 14px;
173
+ padding: 8px;
174
+ }
175
+
176
+ button {
177
+ font-size: 14px;
178
+ }
179
+ }
180
  """) as demo:
181
  gr.Markdown(
182
  """
183
+ <h1>🗣️ AI Voice Assistant</h1>
184
+ <p>Talk to your personal AI! Record your voice, and get a response in both text and audio.</p>
185
+ <p>Powered by advanced AI models for real-time interaction.</p>
186
  """,
187
  elem_id="header"
188
  )
 
257
  });
258
 
259
  document.addEventListener('gradioUpdated', function(event) {
260
+ playAssistantAudio();
 
 
 
 
 
 
 
 
261
  });
262
  }
263
  """)
264
 
265
  return demo
266
 
267
+ # Create and launch the Gradio demo
268
+ demo = create_demo()
269
+ demo.launch()