Spaces:
Running
Running
Update static/script.js
Browse files- 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"
|
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 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
|
533 |
-
|
534 |
-
|
535 |
|
536 |
-
|
537 |
-
|
538 |
-
|
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) {
|