malaknihed commited on
Commit
abad260
Β·
verified Β·
1 Parent(s): 96d3bde

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +34 -40
static/script.js CHANGED
@@ -134,7 +134,7 @@ function loadResumerPage() {
134
  </div>
135
  <h3 class="centered-title">πŸ“ Summary generated :</h3>
136
  <br>
137
- <p id="summaryText" style="font-size: 16px;">${data.summary}</p>
138
  `;
139
 
140
  document.getElementById("documentResult").dataset.summaryText = data.summary;
@@ -254,12 +254,6 @@ function loadResumerPage() {
254
  <div class="logo-top">SMARTDOCS</div>
255
  <div class="logo-bottom">AI</div>
256
  </div>
257
- <a href="principal.html" class="home-link">
258
- <img src="https://cdn-icons-png.flaticon.com/512/1946/1946436.png"
259
- alt="Accueil"
260
- class="home-icon"
261
- style="filter: brightness(0) saturate(100%) invert(71%) sepia(16%) saturate(4251%) hue-rotate(180deg) brightness(104%) contrast(91%);">
262
- </a>
263
  <div class="menu-section">
264
  <button class="menu-btn" id="resumerButton">SUMMARIZE</button>
265
  <button class="menu-btn" id="qesdocButton">DOC-QUESTIONS</button>
@@ -508,41 +502,41 @@ function loadResumerPage() {
508
 
509
  const data = await response.json();
510
 
511
- if (data.translation) {
512
- resultElement.innerHTML = `
513
- <div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
514
- <button id="playVoiceBtn" style="
515
- background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
516
- color: white;
517
- border: none;
518
- padding: 10px 16px;
519
- border-radius: 12px;
520
- cursor: pointer;
521
- font-size: 14px;
522
- box-shadow: 0 4px 6px rgba(0,0,0,0.1);
523
- transition: transform 0.2s;
524
- ">
525
- πŸ”Š Listen to Translation
526
- </button>
527
- </div>
528
- <h3 class="centered-title">🌍 Translation :</h3>
529
- <br>
530
- <p id="translationText" style="font-size: 16px;">${data.translation}</p>
531
- `;
 
 
 
 
 
 
 
532
 
533
- document.getElementById("documentResult").dataset.translationText = data.translation;
534
- document.getElementById("downloadSection").style.display = "block";
535
 
536
- // 🎀 Ajouter l'effet vocal
537
- const playVoiceBtn = document.getElementById("playVoiceBtn");
538
- playVoiceBtn.addEventListener("click", function () {
539
- const textToRead = document.getElementById("translationText").textContent;
540
- const utterance = new SpeechSynthesisUtterance(textToRead);
541
- utterance.lang = "en-US"; // adapte ici selon la langue de ta traduction ("fr-FR" pour du franΓ§ais par exemple)
542
- window.speechSynthesis.speak(utterance);
543
- });
544
- }
545
- else {
546
  resultElement.innerText = "❌ Translation not available.";
547
  }
548
  } catch (error) {
 
134
  </div>
135
  <h3 class="centered-title">πŸ“ Summary generated :</h3>
136
  <br>
137
+ <p id="summaryText">${data.summary}</p>
138
  `;
139
 
140
  document.getElementById("documentResult").dataset.summaryText = data.summary;
 
254
  <div class="logo-top">SMARTDOCS</div>
255
  <div class="logo-bottom">AI</div>
256
  </div>
 
 
 
 
 
 
257
  <div class="menu-section">
258
  <button class="menu-btn" id="resumerButton">SUMMARIZE</button>
259
  <button class="menu-btn" id="qesdocButton">DOC-QUESTIONS</button>
 
502
 
503
  const data = await response.json();
504
 
505
+ if (data.translated_text) {
506
+ resultElement.innerHTML = `
507
+ <div style="display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px;">
508
+ <button id="playAnswerVoiceBtn" style="
509
+ background: linear-gradient(125deg, rgba(163, 94, 237, 0.9) 0%, rgba(65, 159, 232, 0.9) 75%);
510
+ color: white;
511
+ border: none;
512
+ padding: 10px 16px;
513
+ border-radius: 12px;
514
+ cursor: pointer;
515
+ font-size: 14px;
516
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
517
+ transition: transform 0.2s;
518
+ ">
519
+ πŸ”Š Listen to Translation
520
+ </button>
521
+ </div>
522
+ πŸ“ Translation :\n ${data.translated_text}
523
+ `;
524
+
525
+ // 🎀 Add the speech functionality
526
+ const playVoiceBtn = document.getElementById("playAnswerVoiceBtn");
527
+ playVoiceBtn.addEventListener("click", function () {
528
+ const textToRead = data.translated_text;
529
+ const utterance = new SpeechSynthesisUtterance(textToRead);
530
+ utterance.lang = "en-US"; // Adjust the language if necessary
531
+ window.speechSynthesis.speak(utterance);
532
+ });
533
 
534
+ // Store the translated text for later download
535
+ resultElement.dataset.translatedText = data.translated_text;
536
 
537
+ // Show the download section
538
+ document.getElementById("downloadSection").style.display = "block";
539
+ } else {
 
 
 
 
 
 
 
540
  resultElement.innerText = "❌ Translation not available.";
541
  }
542
  } catch (error) {