Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +9 -36
static/script.js
CHANGED
@@ -244,7 +244,8 @@ function loadResumerPage() {
|
|
244 |
//Quand on clique sur le boutton traduction ---------------
|
245 |
|
246 |
|
247 |
-
|
|
|
248 |
document.body.style.setProperty('--background-image', "url('traduction.webp')");
|
249 |
let appContainer = document.createElement("div");
|
250 |
appContainer.classList.add("app-container");
|
@@ -508,41 +509,13 @@ function loadResumerPage() {
|
|
508 |
|
509 |
const data = await response.json();
|
510 |
|
511 |
-
if (data.
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
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) {
|
|
|
244 |
//Quand on clique sur le boutton traduction ---------------
|
245 |
|
246 |
|
247 |
+
ici aussi je veuxque leffet vocale lit le resultat de traduction : resultElement.innerText = "📝 Traduction :\n " + data.translated_text;
|
248 |
+
function loadTraductionPage() {
|
249 |
document.body.style.setProperty('--background-image', "url('traduction.webp')");
|
250 |
let appContainer = document.createElement("div");
|
251 |
appContainer.classList.add("app-container");
|
|
|
509 |
|
510 |
const data = await response.json();
|
511 |
|
512 |
+
if (data.translated_text) {
|
513 |
+
resultElement.innerText = "📝 Traduction :\n " + data.translated_text;
|
514 |
+
// Stocker le texte traduit pour le téléchargement
|
515 |
+
resultElement.dataset.translatedText = data.translated_text;
|
516 |
+
// Afficher les options de téléchargement
|
517 |
+
document.getElementById("downloadSection").style.display = "block";
|
518 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
resultElement.innerText = "❌ Translation not available.";
|
520 |
}
|
521 |
} catch (error) {
|