Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +7 -35
static/script.js
CHANGED
@@ -502,41 +502,13 @@ function loadResumerPage() {
|
|
502 |
|
503 |
const data = await response.json();
|
504 |
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
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) {
|
|
|
502 |
|
503 |
const data = await response.json();
|
504 |
|
505 |
+
if (data.translated_text) {
|
506 |
+
resultElement.innerText = "📝 Traduction :\n " + data.translated_text;
|
507 |
+
// Stocker le texte traduit pour le téléchargement
|
508 |
+
resultElement.dataset.translatedText = data.translated_text;
|
509 |
+
// Afficher les options de téléchargement
|
510 |
+
document.getElementById("downloadSection").style.display = "block";
|
511 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
resultElement.innerText = "❌ Translation not available.";
|
513 |
}
|
514 |
} catch (error) {
|