Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +35 -7
static/script.js
CHANGED
@@ -508,13 +508,41 @@ function loadResumerPage() {
|
|
508 |
|
509 |
const data = await response.json();
|
510 |
|
511 |
-
if (data.
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
resultElement.innerText = "❌ Translation not available.";
|
519 |
}
|
520 |
} catch (error) {
|
|
|
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) {
|