rayhane123 commited on
Commit
ed841d5
·
verified ·
1 Parent(s): cd2e32f

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +129 -128
static/index.html CHANGED
@@ -1,128 +1,129 @@
1
- <!DOCTYPE html>
2
- <html lang="fr">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Document Translator - IA Edition</title>
7
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
9
- <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
11
- <style>
12
- body {
13
- background: linear-gradient(135deg, #1e3c72, #2a5298);
14
- color: white;
15
- text-align: center;
16
- padding: 40px;
17
- }
18
- .container {
19
- max-width: 600px;
20
- background: rgba(255, 255, 255, 0.1);
21
- padding: 20px;
22
- border-radius: 15px;
23
- backdrop-filter: blur(10px);
24
- box-shadow: 0px 0px 15px rgba(255, 255, 255, 0.2);
25
- }
26
- .result-box {
27
- background: white;
28
- color: black;
29
- padding: 15px;
30
- border-radius: 10px;
31
- text-align: left;
32
- max-height: 300px;
33
- overflow-y: auto;
34
- margin-top: 15px;
35
- font-size: 16px;
36
- }
37
- </style>
38
- </head>
39
- <body>
40
- <div class="container">
41
- <h1>📝 AI Document Translator</h1>
42
- <p class="file-info">Formats supportés : <b>TXT, PDF, DOCX, PPTX, XLSX</b></p>
43
-
44
- <form id="uploadForm">
45
- <input type="file" id="fileInput" name="file" class="form-control mt-3" required>
46
-
47
- <select id="src_lang" name="src_lang" class="form-control mt-3">
48
- <option >Francais</option>
49
- <option >Anglais</option>
50
- <option >Arabe</option>
51
- <option >Espagnol</option>
52
- </select>
53
- <select id="tgt_lang" name="tgt_lang" class="form-control mt-3">
54
- <option >Francais</option>
55
- <option >Anglais</option>
56
- <option >Arabe</option>
57
- <option >Espagnol</option>
58
- </select>
59
-
60
- <button type="submit" class="btn btn-success mt-3">Traduire</button>
61
- </form>
62
-
63
- <div class="menu mt-3">
64
- <button type="button" class="btn btn-info" id="openFile">📂 Ouvrir le fichier</button>
65
- <button id="copyText" class="btn btn-secondary" disabled>📋 Copier</button>
66
- <button id="speakText" class="btn btn-dark" disabled>🔊 Écouter</button>
67
- <button id="downloadTxt" class="btn btn-warning" disabled>⬇️ Télécharger en TXT</button>
68
- <button id="downloadPdf" class="btn btn-danger" disabled>📄 Télécharger en PDF</button>
69
- <button id="summarizeText" class="btn btn-primary" disabled>✂️ Résumer</button>
70
- </div>
71
-
72
- <h2 class="mt-4">Résultat :</h2>
73
- <div id="result" class="result-box">Aucun texte traduit pour l’instant...</div>
74
- </div>
75
-
76
- <script>
77
- $(document).ready(function() {
78
- $('#uploadForm').submit(async function(event) {
79
- event.preventDefault();
80
- let formData = new FormData(this);
81
- Swal.fire({ title: 'Traduction en cours...', didOpen: () => { Swal.showLoading(); }});
82
-
83
- let response = await fetch('/upload/', { method: 'POST', body: formData });
84
- let result = await response.json();
85
- Swal.close();
86
- if (result.translated_text) {
87
- $('#result').html(`<b>✨ Traduction :</b><br>${result.translated_text}`);
88
- $('#copyText, #speakText, #downloadTxt, #downloadPdf, #summarizeText').prop("disabled", false);
89
- } else {
90
- $('#result').html(`❌ Erreur: ${result.detail}`);
91
- }
92
- });
93
-
94
- $('#speakText').click(function() {
95
- let text = $('#result').text().trim();
96
- if (!text) return;
97
- let langMap = { "Francais": "fr-FR", "Anglais": "en-US", "Arabe": "ar-SA", "Espagnol": "es-ES" };
98
- let lang = $('#tgt_lang').val();
99
- let utterance = new SpeechSynthesisUtterance(text);
100
- utterance.lang = langMap[lang] || "fr-FR";
101
- utterance.rate = 1;
102
- utterance.pitch = 1;
103
- utterance.volume = 1;
104
- speechSynthesis.speak(utterance);
105
- });
106
-
107
- $('#summarizeText').click(async function() {
108
- let text = $('#result').text().trim();
109
- if (!text) return;
110
- Swal.fire({ title: 'Résumé en cours...', didOpen: () => { Swal.showLoading(); }});
111
-
112
- let response = await fetch('/summarize/', {
113
- method: 'POST',
114
- headers: { 'Content-Type': 'application/json' },
115
- body: JSON.stringify({ text: text })
116
- });
117
- let result = await response.json();
118
- Swal.close();
119
- if (result.summary) {
120
- Swal.fire("Résumé", result.summary, "info");
121
- } else {
122
- Swal.fire("Erreur", "Impossible de résumer le texte.", "error");
123
- }
124
- });
125
- });
126
- </script>
127
- </body>
128
- </html>
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Document Translator - IA Edition</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
10
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
11
+ <style>
12
+ body {
13
+ background: linear-gradient(135deg, #1e3c72, #2a5298);
14
+ color: white;
15
+ text-align: center;
16
+ padding: 40px;
17
+ }
18
+ .container {
19
+ max-width: 600px;
20
+ background: rgba(255, 255, 255, 0.1);
21
+ padding: 20px;
22
+ border-radius: 15px;
23
+ backdrop-filter: blur(10px);
24
+ box-shadow: 0px 0px 15px rgba(255, 255, 255, 0.2);
25
+ }
26
+ .result-box {
27
+ background: white;
28
+ color: black;
29
+ padding: 15px;
30
+ border-radius: 10px;
31
+ text-align: left;
32
+ max-height: 300px;
33
+ overflow-y: auto;
34
+ margin-top: 15px;
35
+ font-size: 16px;
36
+ }
37
+ </style>
38
+ </head>
39
+ <body>
40
+ <div class="container">
41
+ <h1>📝 AI Document Translator</h1>
42
+ <p class="file-info">Formats supportés : <b>TXT, PDF, DOCX, PPTX, XLSX</b></p>
43
+
44
+ <form id="uploadForm">
45
+ <input type="file" id="fileInput" name="file" class="form-control mt-3" required>
46
+
47
+ <select id="src_lang" name="src_lang" class="form-control mt-3">
48
+ <option >Francais</option>
49
+ <option >Anglais</option>
50
+ <option >Arabe</option>
51
+ <option >Espagnol</option>
52
+ </select>
53
+ <select id="tgt_lang" name="tgt_lang" class="form-control mt-3">
54
+ <option >Francais</option>
55
+ <option >Anglais</option>
56
+ <option >Arabe</option>
57
+ <option >Espagnol</option>
58
+ </select>
59
+
60
+ <button type="submit" class="btn btn-success mt-3">Traduire</button>
61
+ </form>
62
+
63
+ <div class="menu mt-3">
64
+ <button type="button" class="btn btn-info" id="openFile">📂 Ouvrir le fichier</button>
65
+ <button id="copyText" class="btn btn-secondary" disabled>📋 Copier</button>
66
+ <button id="speakText" class="btn btn-dark" disabled>🔊 Écouter</button>
67
+ <button id="downloadTxt" class="btn btn-warning" disabled>⬇️ Télécharger en TXT</button>
68
+ <button id="downloadPdf" class="btn btn-danger" disabled>📄 Télécharger en PDF</button>
69
+ <button id="summarizeText" class="btn btn-primary" disabled>✂️ Résumer</button>
70
+ </div>
71
+
72
+ <h2 class="mt-4">Résultat :</h2>
73
+ <div id="result" class="result-box">Aucun texte traduit pour l’instant...</div>
74
+ </div>
75
+
76
+ <script>
77
+ $(document).ready(function() {
78
+ $('#uploadForm').submit(async function(event) {
79
+ event.preventDefault();
80
+ let formData = new FormData(this);
81
+ Swal.fire({ title: 'Traduction en cours...', didOpen: () => { Swal.showLoading(); }});
82
+
83
+ let response = await fetch('https://rayhane123-ai-traduction.hf.space/upload/', { method: 'POST', body: formData });
84
+
85
+ let result = await response.json();
86
+ Swal.close();
87
+ if (result.translated_text) {
88
+ $('#result').html(`<b>✨ Traduction :</b><br>${result.translated_text}`);
89
+ $('#copyText, #speakText, #downloadTxt, #downloadPdf, #summarizeText').prop("disabled", false);
90
+ } else {
91
+ $('#result').html(`❌ Erreur: ${result.detail}`);
92
+ }
93
+ });
94
+
95
+ $('#speakText').click(function() {
96
+ let text = $('#result').text().trim();
97
+ if (!text) return;
98
+ let langMap = { "Francais": "fr-FR", "Anglais": "en-US", "Arabe": "ar-SA", "Espagnol": "es-ES" };
99
+ let lang = $('#tgt_lang').val();
100
+ let utterance = new SpeechSynthesisUtterance(text);
101
+ utterance.lang = langMap[lang] || "fr-FR";
102
+ utterance.rate = 1;
103
+ utterance.pitch = 1;
104
+ utterance.volume = 1;
105
+ speechSynthesis.speak(utterance);
106
+ });
107
+
108
+ $('#summarizeText').click(async function() {
109
+ let text = $('#result').text().trim();
110
+ if (!text) return;
111
+ Swal.fire({ title: 'Résumé en cours...', didOpen: () => { Swal.showLoading(); }});
112
+
113
+ let response = await fetch('/summarize/', {
114
+ method: 'POST',
115
+ headers: { 'Content-Type': 'application/json' },
116
+ body: JSON.stringify({ text: text })
117
+ });
118
+ let result = await response.json();
119
+ Swal.close();
120
+ if (result.summary) {
121
+ Swal.fire("Résumé", result.summary, "info");
122
+ } else {
123
+ Swal.fire("Erreur", "Impossible de résumer le texte.", "error");
124
+ }
125
+ });
126
+ });
127
+ </script>
128
+ </body>
129
+ </html>