Athspi commited on
Commit
c74b21d
·
verified ·
1 Parent(s): 223de58

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +56 -11
static/index.html CHANGED
@@ -192,6 +192,36 @@
192
  .audio-button.loading .loader {
193
  display: block;
194
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  @keyframes spin {
196
  0% { transform: rotate(0deg); }
197
  100% { transform: rotate(360deg); }
@@ -329,7 +359,7 @@
329
  chatArea.scrollTop = chatArea.scrollHeight;
330
  };
331
 
332
- const addMessage = (content, sender, isHTML = false, audioUrl = null) => {
333
  welcomeScreen.classList.add('hidden');
334
 
335
  const messageElement = document.createElement('div');
@@ -344,25 +374,40 @@
344
  }
345
  messageElement.appendChild(contentDiv);
346
 
347
- if (sender === 'ai' && audioUrl) {
348
- const audioButton = document.createElement('button');
349
- audioButton.classList.add('audio-button');
350
- audioButton.dataset.audioUrl = audioUrl;
351
- audioButton.innerHTML = `
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  <svg class="speaker-icon" viewBox="0 0 24 24">
353
  <path d="M3 10v4c0 .55.45 1 1 1h3.5l5.5 5V5L7.5 9H4c-.55 0-1 .45-1 1zm14 0h-1.5c-2.31 0-4.22-1.74-4.47-4H10v12h1.5v-2.22c.25-2.26 2.16-4.22 4.47-4.22H17c1.1 0 2 .9 2 2s-.9 2-2 2h-1.5v2H17c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/>
354
  </svg>
355
  <div class="loader"></div>
356
  `;
357
- audioButton.title = "Listen to response";
358
- audioButton.addEventListener('click', (e) => {
359
  const url = e.currentTarget.dataset.audioUrl;
360
  playAudio(e.currentTarget, url);
361
  });
362
- messageElement.appendChild(audioButton);
363
 
364
  // Auto-play audio
365
- setTimeout(() => audioButton.click(), 300);
366
  }
367
 
368
  chatArea.appendChild(messageElement);
@@ -437,7 +482,7 @@
437
  data.response_html,
438
  'ai',
439
  true,
440
- data.audio_url
441
  );
442
 
443
  } catch (error) {
 
192
  .audio-button.loading .loader {
193
  display: block;
194
  }
195
+
196
+ .download-button {
197
+ position: absolute;
198
+ bottom: 6px;
199
+ right: 45px;
200
+ background: rgba(255, 255, 255, 0.1);
201
+ border: none;
202
+ border-radius: 50%;
203
+ width: 30px;
204
+ height: 30px;
205
+ display: flex;
206
+ align-items: center;
207
+ justify-content: center;
208
+ cursor: pointer;
209
+ transition: background-color 0.2s;
210
+ z-index: 10;
211
+ }
212
+ .download-button:hover {
213
+ background: rgba(255, 255, 255, 0.2);
214
+ }
215
+ .download-button svg {
216
+ width: 18px;
217
+ height: 18px;
218
+ fill: var(--icon-color);
219
+ transition: fill 0.2s;
220
+ }
221
+ .download-button:hover svg {
222
+ fill: #4CAF50;
223
+ }
224
+
225
  @keyframes spin {
226
  0% { transform: rotate(0deg); }
227
  100% { transform: rotate(360deg); }
 
359
  chatArea.scrollTop = chatArea.scrollHeight;
360
  };
361
 
362
+ const addMessage = (content, sender, isHTML = false, audioFilename = null) => {
363
  welcomeScreen.classList.add('hidden');
364
 
365
  const messageElement = document.createElement('div');
 
374
  }
375
  messageElement.appendChild(contentDiv);
376
 
377
+ if (sender === 'ai' && audioFilename) {
378
+ // Add download button
379
+ const downloadButton = document.createElement('button');
380
+ downloadButton.classList.add('download-button');
381
+ downloadButton.title = "Download audio";
382
+ downloadButton.innerHTML = `
383
+ <svg viewBox="0 0 24 24">
384
+ <path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>
385
+ </svg>
386
+ `;
387
+ downloadButton.addEventListener('click', () => {
388
+ window.location.href = `/download/${audioFilename}`;
389
+ });
390
+ messageElement.appendChild(downloadButton);
391
+
392
+ // Add play button
393
+ const playButton = document.createElement('button');
394
+ playButton.classList.add('audio-button');
395
+ playButton.dataset.audioUrl = `/static/audio/${audioFilename}`;
396
+ playButton.innerHTML = `
397
  <svg class="speaker-icon" viewBox="0 0 24 24">
398
  <path d="M3 10v4c0 .55.45 1 1 1h3.5l5.5 5V5L7.5 9H4c-.55 0-1 .45-1 1zm14 0h-1.5c-2.31 0-4.22-1.74-4.47-4H10v12h1.5v-2.22c.25-2.26 2.16-4.22 4.47-4.22H17c1.1 0 2 .9 2 2s-.9 2-2 2h-1.5v2H17c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/>
399
  </svg>
400
  <div class="loader"></div>
401
  `;
402
+ playButton.title = "Listen to response";
403
+ playButton.addEventListener('click', (e) => {
404
  const url = e.currentTarget.dataset.audioUrl;
405
  playAudio(e.currentTarget, url);
406
  });
407
+ messageElement.appendChild(playButton);
408
 
409
  // Auto-play audio
410
+ setTimeout(() => playButton.click(), 300);
411
  }
412
 
413
  chatArea.appendChild(messageElement);
 
482
  data.response_html,
483
  'ai',
484
  true,
485
+ data.audio_filename
486
  );
487
 
488
  } catch (error) {