Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +511 -512
templates/index.html
CHANGED
|
@@ -1,513 +1,512 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="fa">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Karim23657</title>
|
| 7 |
-
<link rel="stylesheet" href="/static/bootstrap.min.css">
|
| 8 |
-
<script src="/static/jquery.min.js"></script>
|
| 9 |
-
|
| 10 |
-
<
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
font-
|
| 16 |
-
font-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
<
|
| 87 |
-
<
|
| 88 |
-
<
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
<div class="
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
<
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
</div>
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
<
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
<
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
<
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
<div class="
|
| 153 |
-
|
| 154 |
-
<div class="col-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
<div class="col-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
<div class="col"><button class="btn btn-light btn-outline-dark btn-block" type="submit" value="
|
| 166 |
-
<div class="col"><button class="btn btn-light btn-outline-dark btn-block" type="submit" value="
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
</
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
<
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
<
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
<
|
| 194 |
-
|
| 195 |
-
<
|
| 196 |
-
|
| 197 |
-
<div class="col-
|
| 198 |
-
<div class="col-3"><a class="btn btn-light btn-outline-dark btn-block" href="/download/
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
<th
|
| 205 |
-
<th
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
$(
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
$(
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
counter
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
overlay.data('
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
const
|
| 275 |
-
const
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
function
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
}
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
$('#
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
let
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
parentEl.find('#
|
| 423 |
-
parentEl.find('#
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
let
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
</body>
|
| 513 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fa">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Karim23657</title>
|
| 7 |
+
<link rel="stylesheet" href="/static/bootstrap.min.css">
|
| 8 |
+
<script src="/static/jquery.min.js"></script>
|
| 9 |
+
|
| 10 |
+
<style>
|
| 11 |
+
@font-face {
|
| 12 |
+
font-family: 'Sahel';
|
| 13 |
+
src: url('/static/sahel.ttf') format('truetype');
|
| 14 |
+
font-weight: normal;
|
| 15 |
+
font-style: normal;
|
| 16 |
+
font-display: swap;
|
| 17 |
+
}
|
| 18 |
+
body {
|
| 19 |
+
font-family: Sahel, sans-serif;
|
| 20 |
+
background-color: #f4f4f9;
|
| 21 |
+
padding: 20px;
|
| 22 |
+
text-align: center;
|
| 23 |
+
direction: rtl; /* Right-to-left direction */
|
| 24 |
+
}
|
| 25 |
+
.content {
|
| 26 |
+
padding: 20px;
|
| 27 |
+
text-align: center;
|
| 28 |
+
}
|
| 29 |
+
.tab-pane {
|
| 30 |
+
display: none;
|
| 31 |
+
}
|
| 32 |
+
.tab-pane.active {
|
| 33 |
+
display: block;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
.visualizer {
|
| 38 |
+
display: flex;
|
| 39 |
+
justify-content: center;
|
| 40 |
+
align-items: flex-end;
|
| 41 |
+
height: 30px;
|
| 42 |
+
gap: 3px;
|
| 43 |
+
margin: 20px 0;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.bar {
|
| 47 |
+
width: 3px;
|
| 48 |
+
background: #1db9b9;
|
| 49 |
+
border-radius: 3px;
|
| 50 |
+
animation: bounce 1s infinite;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
@keyframes bounce {
|
| 54 |
+
|
| 55 |
+
0%,
|
| 56 |
+
100% {
|
| 57 |
+
height: 5px;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
50% {
|
| 61 |
+
height: 20px;
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
</style>
|
| 65 |
+
</head>
|
| 66 |
+
<body>
|
| 67 |
+
|
| 68 |
+
<div class="container mt-5">
|
| 69 |
+
<!-- Tabs -->
|
| 70 |
+
<ul class="nav nav-tabs">
|
| 71 |
+
<li class="nav-item">
|
| 72 |
+
<a class="nav-link active" href="#" data-target="#home">متن به گفتار 🗣️</a>
|
| 73 |
+
</li>
|
| 74 |
+
<li class="nav-item">
|
| 75 |
+
<a class="nav-link" href="#" data-target="#menu1">ویرایش تلفظ</a>
|
| 76 |
+
</li>
|
| 77 |
+
<li class="nav-item">
|
| 78 |
+
<a class="nav-link" href="#" data-target="#menu2">واژه های اخیر</a>
|
| 79 |
+
</li>
|
| 80 |
+
</ul>
|
| 81 |
+
|
| 82 |
+
<!-- Tab Content -->
|
| 83 |
+
<div class="tab-content">
|
| 84 |
+
<div id="home" class="container tab-pane active content"><br>
|
| 85 |
+
<h3 class="mb-3">متن به گفتار 🗣️</h3>
|
| 86 |
+
<div class="row">
|
| 87 |
+
<form class="form col-md-6 input" dir="rtl" id="tts">
|
| 88 |
+
<input type="hidden" name="tab" value="tts">
|
| 89 |
+
<div class="form-group">
|
| 90 |
+
<div class="rounded p-2 border" style="background-color: #f8f9fa;">
|
| 91 |
+
<div class="form-group">
|
| 92 |
+
|
| 93 |
+
<label for="textarea" class="d-flex justify-content-start">متن:</label>
|
| 94 |
+
<textarea class="form-control" id="textarea" rows="3" name="text" required></textarea>
|
| 95 |
+
|
| 96 |
+
</div>
|
| 97 |
+
<div class="form-group">
|
| 98 |
+
|
| 99 |
+
<label class="d-flex justify-content-start">انتخاب صدا:</label>
|
| 100 |
+
|
| 101 |
+
{{ components|safe }}
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
|
| 109 |
+
<div class="form-group">
|
| 110 |
+
<div class="row mb-3">
|
| 111 |
+
<div class="col">
|
| 112 |
+
<button class="btn btn-light btn-outline-dark btn-block" type="submit" value="submit">بگو</button>
|
| 113 |
+
</div>
|
| 114 |
+
<div class="col">
|
| 115 |
+
<button class="btn btn-light btn-outline-dark btn-block" value="stop">توقف</button>
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
</form>
|
| 121 |
+
|
| 122 |
+
<div class="form-group col-md-6 output">
|
| 123 |
+
<div class="rounded p-2 border" style="background-color: #f8f9fa;">
|
| 124 |
+
|
| 125 |
+
<label for="tts-audio" class="d-flex justify-content-start">صوت:</label>
|
| 126 |
+
<audio controls id="tts-audio" class="col-12 result">Your browser does not support the audio element.</audio>
|
| 127 |
+
|
| 128 |
+
<label for="status" class="d-flex justify-content-start">وضعیت:</label>
|
| 129 |
+
<textarea class="form-control result" id="status" rows="2" disabled></textarea>
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
</div>
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
</div>
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
<div id="menu1" class="container tab-pane content">
|
| 142 |
+
<br>
|
| 143 |
+
<h3 class="mb-3">ویرایش تلفظ واژه</h3>
|
| 144 |
+
|
| 145 |
+
<div class="row">
|
| 146 |
+
|
| 147 |
+
<div class="form-group col-md-6">
|
| 148 |
+
|
| 149 |
+
<form dir="rtl" class="form-group " id="phonemize">
|
| 150 |
+
<input type="hidden" name="tab" value="phonemize">
|
| 151 |
+
<div class="rounded p-2 border mb-3" style="background-color: #f8f9fa;">
|
| 152 |
+
<div class="form-group row align-items-center">
|
| 153 |
+
<div class="col-2"><label for="input_word" class="col-form-label">واژه:</label></div>
|
| 154 |
+
<div class="col-10"><input type="text" class="form-control" id="input_word" name="word" placeholder="واژه را وارد کنید"></div>
|
| 155 |
+
</div>
|
| 156 |
+
<div class="form-group row align-items-center">
|
| 157 |
+
<div class="col-2"><label for="phonetics" class="d-flex justify-content-start">تلفظ:</label></div>
|
| 158 |
+
<div class="col-10"><input type="text" class="form-control result" id="phonetics" name="phonetic" placeholder="تلفظ را وارد کنید"></div>
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
</div>
|
| 162 |
+
|
| 163 |
+
<div class="form-group row align-items-center">
|
| 164 |
+
<div class="col"><button class="btn btn-light btn-outline-dark btn-block" type="submit" value="phonemize">آوانویسی</button></div>
|
| 165 |
+
<div class="col"><button class="btn btn-light btn-outline-dark btn-block" type="submit" value="say">بگو</button></div>
|
| 166 |
+
<div class="col"><button class="btn btn-light btn-outline-dark btn-block" type="submit" value="send">ارسال واژه</button></div>
|
| 167 |
+
</div>
|
| 168 |
+
</form>
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
<div class="form-group col-md-6">
|
| 172 |
+
<div class="rounded p-2 border" style="background-color: #f8f9fa;">
|
| 173 |
+
|
| 174 |
+
<label for="audio" class="d-flex justify-content-start">صوت:</label>
|
| 175 |
+
<audio controls id="audio" class="col-12 result">Your browser does not support the audio element.</audio>
|
| 176 |
+
|
| 177 |
+
<label for="status" class="d-flex justify-content-start">وضعیت:</label>
|
| 178 |
+
<textarea class="form-control result" id="status" rows="2" disabled></textarea>
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
</div>
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
<div id="menu2" class="container tab-pane content"><br>
|
| 192 |
+
<h3>واژه هایی که ثبت شده</h3>
|
| 193 |
+
<form dir="rtl" class="form-group " id="words">
|
| 194 |
+
<input type="hidden" name="tab" value="words">
|
| 195 |
+
<div class="form-group row align-items-center">
|
| 196 |
+
<div class="col-6"><button class="btn btn-light btn-outline-dark btn-block" type="submit" value="words">بروز رسانی</button></div>
|
| 197 |
+
<div class="col-3"><a class="btn btn-light btn-outline-dark btn-block" href="/download/fa_dict">dict ⇩</a></div>
|
| 198 |
+
<div class="col-3"><a class="btn btn-light btn-outline-dark btn-block" href="/download/fa_extra">list ⇩</a></div>
|
| 199 |
+
</div>
|
| 200 |
+
<table class="table table-bordered table-striped result">
|
| 201 |
+
<thead>
|
| 202 |
+
<tr>
|
| 203 |
+
<th>#</th>
|
| 204 |
+
<th>واژه</th>
|
| 205 |
+
<th>تلفظ</th>
|
| 206 |
+
</tr>
|
| 207 |
+
</thead>
|
| 208 |
+
<tbody>
|
| 209 |
+
|
| 210 |
+
</tbody>
|
| 211 |
+
</table>
|
| 212 |
+
</form>
|
| 213 |
+
</div>
|
| 214 |
+
</div>
|
| 215 |
+
</div>
|
| 216 |
+
|
| 217 |
+
<script>
|
| 218 |
+
$(document).ready(function() {
|
| 219 |
+
|
| 220 |
+
$('.nav-link').on('click', function(e) {
|
| 221 |
+
e.preventDefault();
|
| 222 |
+
$('.nav-link').removeClass('active');
|
| 223 |
+
$(this).addClass('active');
|
| 224 |
+
|
| 225 |
+
var target = $(this).data('target');
|
| 226 |
+
$('.tab-pane').removeClass('active');
|
| 227 |
+
$(target).addClass('active');
|
| 228 |
+
});
|
| 229 |
+
|
| 230 |
+
let currentTaskId = null;
|
| 231 |
+
let resultCheckInterval = null;
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
function createLoadingOverlay(element) {
|
| 235 |
+
const overlay = $("<div>", {
|
| 236 |
+
class: "loading-overlay position-absolute top-0 start-0 d-flex justify-content-center align-items-center bg-secondary bg-opacity-50",
|
| 237 |
+
css: {
|
| 238 |
+
zIndex: 1000,
|
| 239 |
+
fontFamily: 'sans-serif' // Or a suitable Persian font
|
| 240 |
+
}
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
+
// Use RTL layout for Persian text
|
| 244 |
+
overlay.html('<span class="spinner-border spinner-border-sm text-light ms-2" role="status"></span><span class="text-light mr-3" dir="rtl">در حال بارگذاری... <span id="loading-counter">0.00</span></span>');
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
$("body").append(overlay);
|
| 248 |
+
|
| 249 |
+
let counter = 0.00;
|
| 250 |
+
const counterInterval = setInterval(() => {
|
| 251 |
+
counter = parseFloat((counter + 0.01).toFixed(2));
|
| 252 |
+
$("#loading-counter", overlay).text(counter.toFixed(2));
|
| 253 |
+
}, 10);
|
| 254 |
+
|
| 255 |
+
overlay.data('counterInterval', counterInterval);
|
| 256 |
+
overlay.data('element', element);
|
| 257 |
+
|
| 258 |
+
updateOverlayPosition(overlay);
|
| 259 |
+
|
| 260 |
+
$(window).on("resize.overlay scroll.overlay", function() {
|
| 261 |
+
updateOverlayPosition(overlay);
|
| 262 |
+
});
|
| 263 |
+
|
| 264 |
+
return overlay;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
function updateOverlayPosition(overlay) {
|
| 268 |
+
const element = overlay.data('element');
|
| 269 |
+
if (!element || !element.length) {
|
| 270 |
+
return;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
const elementPosition = element.offset();
|
| 274 |
+
const elementWidth = element.outerWidth();
|
| 275 |
+
const elementHeight = element.outerHeight();
|
| 276 |
+
|
| 277 |
+
overlay.css({
|
| 278 |
+
top: elementPosition.top,
|
| 279 |
+
left: elementPosition.left,
|
| 280 |
+
width: elementWidth,
|
| 281 |
+
height: elementHeight
|
| 282 |
+
});
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
function destroyOverlayAll(elements) {
|
| 286 |
+
elements.each(function() {
|
| 287 |
+
const $this = $(this);
|
| 288 |
+
destroyOverlay($this);
|
| 289 |
+
});
|
| 290 |
+
}
|
| 291 |
+
function destroyOverlay(element) {
|
| 292 |
+
const overlay = $(".loading-overlay").filter(function() {
|
| 293 |
+
return $(this).data('element')[0] === element[0];
|
| 294 |
+
});
|
| 295 |
+
if (overlay.length) {
|
| 296 |
+
clearInterval(overlay.data('counterInterval'));
|
| 297 |
+
$(window).off("resize.overlay scroll.overlay");
|
| 298 |
+
overlay.remove();
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
$('#tts').on('submit', function(e) {
|
| 304 |
+
e.preventDefault();
|
| 305 |
+
const formData = new FormData(this);
|
| 306 |
+
$(this).parent().find('.result').each(function() {
|
| 307 |
+
const $this = $(this);
|
| 308 |
+
const overlay = createLoadingOverlay($this);
|
| 309 |
+
});
|
| 310 |
+
|
| 311 |
+
const clickedButton = $(e.originalEvent.submitter);
|
| 312 |
+
|
| 313 |
+
if(clickedButton.val()=='submit'){
|
| 314 |
+
|
| 315 |
+
clickedButton.prop('disabled',true)
|
| 316 |
+
|
| 317 |
+
$.ajax({
|
| 318 |
+
url: '/submit',
|
| 319 |
+
type: 'POST',
|
| 320 |
+
data: formData,
|
| 321 |
+
contentType: false,
|
| 322 |
+
processData: false,
|
| 323 |
+
success: function(data) {
|
| 324 |
+
currentTaskId = data.task_id;
|
| 325 |
+
const position = data.position;
|
| 326 |
+
//$('#queuePosition').html(`Your task is in position: ${position}`);
|
| 327 |
+
|
| 328 |
+
checkResult(currentTaskId);
|
| 329 |
+
},
|
| 330 |
+
error: function(xhr) {
|
| 331 |
+
destroyOverlayAll($('#tts').parent().find('.result'));
|
| 332 |
+
if (xhr.status === 429) {
|
| 333 |
+
//$('#queuePosition').html('Error: Task queue is full. Please try again later.');
|
| 334 |
+
clickedButton.prop('disabled',false)
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
});
|
| 338 |
+
}else if(clickedButton.val()=='stop'){
|
| 339 |
+
|
| 340 |
+
if (currentTaskId) {
|
| 341 |
+
$.post(`/stop/${currentTaskId}`, function(data) {
|
| 342 |
+
destroyOverlayAll($('#tts').parent().find('.result'));
|
| 343 |
+
clearInterval(resultCheckInterval);
|
| 344 |
+
}).fail(function() {
|
| 345 |
+
//$('#queuePosition').html('Error stopping the task. It may have already completed.');
|
| 346 |
+
});
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
function checkResult(taskId) {
|
| 353 |
+
resultCheckInterval = setInterval(function() {
|
| 354 |
+
$.get(`/result/${taskId}/tts`, function(data) {
|
| 355 |
+
if (data.status === "completed") {
|
| 356 |
+
clearInterval(resultCheckInterval);
|
| 357 |
+
$('#status').val(data.result.status);
|
| 358 |
+
$('#tts-audio').attr('src', data.result.audio); // Update audio source
|
| 359 |
+
destroyOverlayAll($('#tts').parent().find('.result'));
|
| 360 |
+
clickedButton.prop('disabled',false)
|
| 361 |
+
|
| 362 |
+
}
|
| 363 |
+
});
|
| 364 |
+
}, 1000); // Check every second for a faster response
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
});
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
$('#phonemize').on('submit', function(e) {
|
| 372 |
+
e.preventDefault();
|
| 373 |
+
const formData = new FormData(this);
|
| 374 |
+
|
| 375 |
+
let parentEl = $(this).parent().parent();
|
| 376 |
+
let result_holders = parentEl.find('.result');
|
| 377 |
+
result_holders.each(function() {
|
| 378 |
+
const $this = $(this);
|
| 379 |
+
const overlay = createLoadingOverlay($this);
|
| 380 |
+
});
|
| 381 |
+
|
| 382 |
+
const clickedButton = $(e.originalEvent.submitter);
|
| 383 |
+
console.log(clickedButton.val());
|
| 384 |
+
|
| 385 |
+
if(['say','phonemize','send'].includes(clickedButton.val())){
|
| 386 |
+
|
| 387 |
+
clickedButton.prop('disabled',true);
|
| 388 |
+
formData.append('task',clickedButton.val());
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
$.ajax({
|
| 392 |
+
url: '/submit',
|
| 393 |
+
type: 'POST',
|
| 394 |
+
data: formData,
|
| 395 |
+
contentType: false,
|
| 396 |
+
processData: false,
|
| 397 |
+
success: function(data) {
|
| 398 |
+
currentTaskId = data.task_id;
|
| 399 |
+
const position = data.position;
|
| 400 |
+
//$('#queuePosition').html(`Your task is in position: ${position}`);
|
| 401 |
+
|
| 402 |
+
checkResult(currentTaskId);
|
| 403 |
+
},
|
| 404 |
+
error: function(xhr) {
|
| 405 |
+
destroyOverlayAll(result_holders);
|
| 406 |
+
if (xhr.status === 429) {
|
| 407 |
+
//$('#queuePosition').html('Error: Task queue is full. Please try again later.');
|
| 408 |
+
clickedButton.prop('disabled',false)
|
| 409 |
+
}
|
| 410 |
+
}
|
| 411 |
+
});
|
| 412 |
+
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
function checkResult(taskId) {
|
| 417 |
+
resultCheckInterval = setInterval(function() {
|
| 418 |
+
$.get(`/result/${taskId}/phonemize`, function(data) {
|
| 419 |
+
if (data.status === "completed") {
|
| 420 |
+
clearInterval(resultCheckInterval);
|
| 421 |
+
parentEl.find('#phonetics').val(data.result.phonemes);
|
| 422 |
+
parentEl.find('#status').val(data.result.status);
|
| 423 |
+
parentEl.find('#audio').attr('src', data.result.audio); // Update audio source
|
| 424 |
+
destroyOverlayAll(result_holders);
|
| 425 |
+
clickedButton.prop('disabled',false)
|
| 426 |
+
|
| 427 |
+
}
|
| 428 |
+
});
|
| 429 |
+
}, 1000); // Check every second for a faster response
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
});
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
$('#words').on('submit', function(e) {
|
| 436 |
+
e.preventDefault();
|
| 437 |
+
let parentEl = $(this).parent();
|
| 438 |
+
let result_holders = parentEl.find('.result');
|
| 439 |
+
const formData = new FormData(this);
|
| 440 |
+
result_holders.each(function() {
|
| 441 |
+
const $this = $(this);
|
| 442 |
+
const overlay = createLoadingOverlay($this);
|
| 443 |
+
});
|
| 444 |
+
|
| 445 |
+
const clickedButton = $(e.originalEvent.submitter);
|
| 446 |
+
console.log(clickedButton.val());
|
| 447 |
+
|
| 448 |
+
|
| 449 |
+
clickedButton.prop('disabled',true);
|
| 450 |
+
formData.append('task',clickedButton.val());
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
$.ajax({
|
| 454 |
+
url: '/submit',
|
| 455 |
+
type: 'POST',
|
| 456 |
+
data: formData,
|
| 457 |
+
contentType: false,
|
| 458 |
+
processData: false,
|
| 459 |
+
success: function(data) {
|
| 460 |
+
currentTaskId = data.task_id;
|
| 461 |
+
const position = data.position;
|
| 462 |
+
//$('#queuePosition').html(`Your task is in position: ${position}`);
|
| 463 |
+
|
| 464 |
+
checkResult(currentTaskId);
|
| 465 |
+
},
|
| 466 |
+
error: function(xhr) {
|
| 467 |
+
destroyOverlayAll(result_holders);
|
| 468 |
+
if (xhr.status === 429) {
|
| 469 |
+
//$('#queuePosition').html('Error: Task queue is full. Please try again later.');
|
| 470 |
+
clickedButton.prop('disabled',false)
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
});
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
function checkResult(taskId) {
|
| 479 |
+
resultCheckInterval = setInterval(function() {
|
| 480 |
+
$.get(`/result/${taskId}/words`, function(data) {
|
| 481 |
+
if (data.status === "completed") {
|
| 482 |
+
clearInterval(resultCheckInterval);
|
| 483 |
+
let tbody = parentEl.find('tbody');
|
| 484 |
+
tbody.empty();
|
| 485 |
+
data.result.forEach(function(item, index) {
|
| 486 |
+
tbody.append(`<tr><td>${index + 1}</td><td>${item.word}</td><td>${item.phonetic}</td></tr>`);
|
| 487 |
+
});
|
| 488 |
+
destroyOverlayAll(result_holders);
|
| 489 |
+
clickedButton.prop('disabled',false)
|
| 490 |
+
|
| 491 |
+
}
|
| 492 |
+
});
|
| 493 |
+
}, 1000); // Check every second for a faster response
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
});
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
|
| 503 |
+
});
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
</script>
|
| 510 |
+
|
| 511 |
+
</body>
|
|
|
|
| 512 |
</html>
|