malaknihed commited on
Commit
d01cb87
·
verified ·
1 Parent(s): b82cd3d

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +28 -4
static/script.js CHANGED
@@ -141,12 +141,30 @@ function loadResumerPage() {
141
  document.getElementById("downloadSection").style.display = "block";
142
 
143
  const playVoiceBtn = document.getElementById("playVoiceBtn");
144
- playVoiceBtn.addEventListener("click", function () {
 
 
 
 
 
 
 
 
 
145
  const textToRead = document.getElementById("summaryText").textContent;
146
- const utterance = new SpeechSynthesisUtterance(textToRead);
147
- utterance.lang = "en-US"; // ou "fr-FR" si ton résumé est en français
 
 
 
 
 
 
148
  window.speechSynthesis.speak(utterance);
149
- });
 
 
 
150
  }
151
  else {
152
  resultElement.innerText = "❌ Summary not available.";
@@ -253,6 +271,12 @@ function loadResumerPage() {
253
  <div class="logo-top">SMARTDOCS</div>
254
  <div class="logo-bottom">AI</div>
255
  </div>
 
 
 
 
 
 
256
  <div class="menu-section">
257
  <button class="menu-btn" id="resumerButton">SUMMARIZE</button>
258
  <button class="menu-btn" id="qesdocButton">DOC-QUESTIONS</button>
 
141
  document.getElementById("downloadSection").style.display = "block";
142
 
143
  const playVoiceBtn = document.getElementById("playVoiceBtn");
144
+ let isSpeaking = false;
145
+ let utterance = null;
146
+
147
+ playVoiceBtn.addEventListener("click", function () {
148
+ if (isSpeaking) {
149
+ // Si la lecture est en cours, on l'arrête
150
+ window.speechSynthesis.cancel();
151
+ isSpeaking = false;
152
+ } else {
153
+ // Sinon, on commence à lire
154
  const textToRead = document.getElementById("summaryText").textContent;
155
+ utterance = new SpeechSynthesisUtterance(textToRead);
156
+ utterance.lang = "en-US"; // ou "fr-FR"
157
+
158
+ utterance.onend = function () {
159
+ // Lecture terminée
160
+ isSpeaking = false;
161
+ };
162
+
163
  window.speechSynthesis.speak(utterance);
164
+ isSpeaking = true;
165
+ }
166
+ });
167
+
168
  }
169
  else {
170
  resultElement.innerText = "❌ Summary not available.";
 
271
  <div class="logo-top">SMARTDOCS</div>
272
  <div class="logo-bottom">AI</div>
273
  </div>
274
+ <a href="principal.html" class="home-link">
275
+ <img src="https://cdn-icons-png.flaticon.com/512/1946/1946436.png"
276
+ alt="Accueil"
277
+ class="home-icon"
278
+ style="filter: brightness(0) saturate(100%) invert(71%) sepia(16%) saturate(4251%) hue-rotate(180deg) brightness(104%) contrast(91%);">
279
+ </a>
280
  <div class="menu-section">
281
  <button class="menu-btn" id="resumerButton">SUMMARIZE</button>
282
  <button class="menu-btn" id="qesdocButton">DOC-QUESTIONS</button>