Update index.html
Browse files- index.html +163 -1024
index.html
CHANGED
@@ -13,13 +13,15 @@
|
|
13 |
--panel-bg: #FFFFFF;
|
14 |
--panel-border: #E8EEF3;
|
15 |
--text-primary: #121826;
|
16 |
-
--text-secondary: #5C677D;
|
17 |
-
--accent-primary: #3B82F6;
|
18 |
--accent-primary-hover: #2563EB;
|
19 |
-
--accent-secondary: #10B981;
|
20 |
--accent-secondary-hover: #059669;
|
21 |
--input-bg: #F8FAFC;
|
22 |
-
--
|
|
|
|
|
23 |
|
24 |
--radius-card: 24px;
|
25 |
--radius-input: 14px;
|
@@ -27,32 +29,8 @@
|
|
27 |
--shadow-medium: 0 6px 16px -2px rgba(26, 32, 44, 0.08), 0 3px 8px -3px rgba(26,32,44,0.05);
|
28 |
--shadow-strong: 0 10px 25px -5px rgba(26, 32, 44, 0.12), 0 6px 15px -6px rgba(26,32,44,0.08);
|
29 |
--transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
30 |
-
--transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
|
31 |
-
|
32 |
-
/* Custom Audio Player Colors */
|
33 |
-
--waveform-color-active: #3B82F6; /* Blue for active part of waveform */
|
34 |
-
--waveform-color-inactive: #D0D9E6; /* Lighter shade for inactive part of waveform */
|
35 |
-
--waveform-dashed-line-color: #E0E4E9; /* Very light grey for the dashed line */
|
36 |
}
|
37 |
|
38 |
-
@keyframes fadeInDown {
|
39 |
-
from { opacity: 0; transform: translateY(-20px); }
|
40 |
-
to { opacity: 1; transform: translateY(0); }
|
41 |
-
}
|
42 |
-
@keyframes fadeInUp {
|
43 |
-
from { opacity: 0; transform: translateY(20px); }
|
44 |
-
to { opacity: 1; transform: translateY(0); }
|
45 |
-
}
|
46 |
-
@keyframes modalZoomIn {
|
47 |
-
from { opacity: 0; transform: scale(0.8) translateY(20px); }
|
48 |
-
to { opacity: 1; transform: scale(1) translateY(0); }
|
49 |
-
}
|
50 |
-
@keyframes modalZoomOut {
|
51 |
-
from { opacity: 1; transform: scale(1) translateY(0); }
|
52 |
-
to { opacity: 0; transform: scale(0.8) translateY(20px); }
|
53 |
-
}
|
54 |
-
|
55 |
-
/* Keyframe for loading spinner in button */
|
56 |
@keyframes spin {
|
57 |
from { transform: rotate(0deg); }
|
58 |
to { transform: rotate(360deg); }
|
@@ -69,7 +47,6 @@
|
|
69 |
padding: 2.5rem 0;
|
70 |
min-height: 100vh;
|
71 |
-webkit-font-smoothing: antialiased;
|
72 |
-
-moz-osx-font-smoothing: grayscale;
|
73 |
display: flex;
|
74 |
justify-content: center;
|
75 |
align-items: flex-start;
|
@@ -82,382 +59,14 @@
|
|
82 |
margin: 0 auto;
|
83 |
}
|
84 |
|
85 |
-
.app-header {
|
86 |
-
padding: 0.5rem 0 2.5rem 0;
|
87 |
-
text-align: center;
|
88 |
-
margin-bottom: 1.5rem;
|
89 |
-
animation: fadeInDown 0.8s 0.1s ease-out backwards;
|
90 |
-
}
|
91 |
-
.app-header h1 {
|
92 |
-
font-size: 2.1em;
|
93 |
-
font-weight: 900;
|
94 |
-
margin:0 0 0.6rem 0;
|
95 |
-
background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
|
96 |
-
-webkit-background-clip: text;
|
97 |
-
-webkit-text-fill-color: transparent;
|
98 |
-
letter-spacing: -0.5px;
|
99 |
-
}
|
100 |
-
.app-header p {
|
101 |
-
font-size: 1em;
|
102 |
-
color: var(--text-secondary);
|
103 |
-
margin-top:0;
|
104 |
-
opacity: 0.85;
|
105 |
-
font-weight: 400;
|
106 |
-
line-height: 1.6;
|
107 |
-
}
|
108 |
-
|
109 |
.main-content {
|
110 |
padding: 2.5rem;
|
111 |
background-color: var(--panel-bg);
|
112 |
border-radius: var(--radius-card);
|
113 |
box-shadow: var(--shadow-strong);
|
114 |
border: 1px solid var(--panel-border);
|
115 |
-
animation: fadeInUp 0.8s 0.3s ease-out backwards;
|
116 |
-
}
|
117 |
-
|
118 |
-
.form-group { margin-bottom: 2rem; }
|
119 |
-
|
120 |
-
.label-with-info {
|
121 |
-
display: flex;
|
122 |
-
align-items: center;
|
123 |
-
gap: 0.5rem;
|
124 |
-
margin-bottom: 1rem;
|
125 |
-
}
|
126 |
-
.label-with-info label {
|
127 |
-
margin-bottom: 0;
|
128 |
-
}
|
129 |
-
|
130 |
-
.info-icon {
|
131 |
-
display: inline-flex;
|
132 |
-
align-items: center;
|
133 |
-
justify-content: center;
|
134 |
-
width: 22px;
|
135 |
-
height: 22px;
|
136 |
-
border-radius: 50%;
|
137 |
-
background-color: var(--input-bg);
|
138 |
-
border: 1px solid var(--panel-border);
|
139 |
-
color: var(--text-secondary);
|
140 |
-
font-size: 0.9em;
|
141 |
-
font-weight: 700;
|
142 |
-
cursor: pointer;
|
143 |
-
position: relative;
|
144 |
-
transition: var(--transition-smooth);
|
145 |
-
user-select: none;
|
146 |
-
}
|
147 |
-
.info-icon:hover, .info-icon:focus {
|
148 |
-
background-color: var(--accent-primary);
|
149 |
-
color: white;
|
150 |
-
border-color: var(--accent-primary);
|
151 |
-
transform: scale(1.1);
|
152 |
-
outline: none;
|
153 |
-
}
|
154 |
-
|
155 |
-
label {
|
156 |
-
display: block;
|
157 |
-
font-weight: 700;
|
158 |
-
color: var(--text-primary);
|
159 |
-
font-size: 1.05em;
|
160 |
-
margin-bottom: 0.8rem;
|
161 |
-
}
|
162 |
-
|
163 |
-
textarea, input[type="text"] {
|
164 |
-
width: 100%;
|
165 |
-
padding: 0.9rem 1.1rem;
|
166 |
-
border-radius: var(--radius-input);
|
167 |
-
border: 1px solid var(--panel-border);
|
168 |
-
background-color: var(--input-bg);
|
169 |
-
color: var(--text-primary);
|
170 |
-
box-shadow: var(--shadow-subtle) inset;
|
171 |
-
font-family: var(--app-font);
|
172 |
-
font-size: 1rem;
|
173 |
-
box-sizing: border-box;
|
174 |
-
transition: var(--transition-smooth);
|
175 |
-
}
|
176 |
-
textarea:focus, input[type="text"]:focus {
|
177 |
-
outline: none;
|
178 |
-
border-color: var(--input-border-focus);
|
179 |
-
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), var(--shadow-subtle) inset;
|
180 |
-
background-color: #fff;
|
181 |
-
}
|
182 |
-
textarea { min-height: 100px; resize: vertical; }
|
183 |
-
|
184 |
-
.char-counter-wrapper {
|
185 |
-
font-size: 0.85em;
|
186 |
-
color: var(--text-secondary);
|
187 |
-
text-align: left;
|
188 |
-
margin-top: 0.5rem;
|
189 |
-
padding: 0 0.2rem;
|
190 |
-
}
|
191 |
-
#char-count { font-weight: 600; color: var(--accent-primary); }
|
192 |
-
|
193 |
-
|
194 |
-
/* --- نمایش گوینده منتخب --- */
|
195 |
-
#selected-speaker-display { text-align: center; margin-top: 1rem; position: relative; }
|
196 |
-
#selected-speaker-card {
|
197 |
-
display: inline-flex;
|
198 |
-
align-items: center;
|
199 |
-
background: linear-gradient(135deg, var(--input-bg) 0%, #fff 100%);
|
200 |
-
border-radius: var(--radius-card);
|
201 |
-
padding: 1rem 1.2rem;
|
202 |
-
box-shadow: var(--shadow-medium);
|
203 |
-
border: 1px solid var(--panel-border);
|
204 |
-
transition: var(--transition-bounce);
|
205 |
-
position: relative;
|
206 |
-
margin-bottom: 1.2rem;
|
207 |
-
cursor: pointer;
|
208 |
-
}
|
209 |
-
#selected-speaker-card:hover {
|
210 |
-
transform: translateY(-6px) scale(1.03);
|
211 |
-
box-shadow: var(--shadow-strong);
|
212 |
-
}
|
213 |
-
#selected-speaker-card img {
|
214 |
-
width: 75px; height: 75px;
|
215 |
-
border-radius: 50%;
|
216 |
-
object-fit: cover;
|
217 |
-
margin-left: 18px;
|
218 |
-
border: 3px solid var(--accent-secondary);
|
219 |
-
box-shadow: 0 0 12px -2px rgba(16, 185, 129, 0.5);
|
220 |
-
background-color: #e0e0e0;
|
221 |
-
transition: var(--transition-smooth);
|
222 |
-
}
|
223 |
-
#selected-speaker-card:hover img {
|
224 |
-
transform: scale(1.08) rotate(3deg);
|
225 |
-
}
|
226 |
-
#selected-speaker-info h3 { margin: 0; font-size: 1.35em; font-weight: 800; color: var(--text-primary); }
|
227 |
-
#selected-speaker-info p { margin: 4px 0 0; color: var(--text-secondary); font-size: 0.88em; font-weight: 500; }
|
228 |
-
|
229 |
-
#change-speaker-btn {
|
230 |
-
display: inline-flex;
|
231 |
-
align-items: center;
|
232 |
-
justify-content: center;
|
233 |
-
margin: 0 auto;
|
234 |
-
padding: 10px 20px;
|
235 |
-
border-radius: var(--radius-input);
|
236 |
-
background: linear-gradient(45deg, var(--accent-primary-hover), var(--accent-primary));
|
237 |
-
border: none;
|
238 |
-
color: #fff;
|
239 |
-
cursor: pointer;
|
240 |
-
font-family: var(--app-font); font-weight: 600;
|
241 |
-
font-size: 1em;
|
242 |
-
transition: var(--transition-smooth);
|
243 |
-
box-shadow: 0 4px 10px -2px rgba(59, 130, 246, 0.35), var(--shadow-subtle);
|
244 |
-
}
|
245 |
-
#change-speaker-btn:hover {
|
246 |
-
background: linear-gradient(45deg, var(--accent-primary), var(--accent-primary-hover));
|
247 |
-
transform: translateY(-3px) scale(1.05);
|
248 |
-
box-shadow: 0 6px 12px -3px rgba(59, 130, 246, 0.45), var(--shadow-medium);
|
249 |
-
}
|
250 |
-
#change-speaker-btn svg {
|
251 |
-
width: 1.1em;
|
252 |
-
height: 1.1em;
|
253 |
-
margin-right: 0.5em;
|
254 |
-
fill: currentColor;
|
255 |
-
}
|
256 |
-
|
257 |
-
|
258 |
-
/* --- مودال عمومی --- */
|
259 |
-
.modal-overlay {
|
260 |
-
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
|
261 |
-
background-color: rgba(18, 24, 38, 0.6);
|
262 |
-
backdrop-filter: blur(8px) saturate(150%);
|
263 |
-
display: none; /* Hidden by default */
|
264 |
-
align-items: center; justify-content: center;
|
265 |
-
z-index: 1000; opacity: 0;
|
266 |
-
transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
267 |
-
}
|
268 |
-
.modal-overlay.visible { display: flex; opacity: 1; }
|
269 |
-
|
270 |
-
.modal-dialog {
|
271 |
-
background: var(--panel-bg);
|
272 |
-
padding: 2rem;
|
273 |
-
border-radius: var(--radius-card);
|
274 |
-
width: 90%;
|
275 |
-
box-shadow: var(--shadow-strong);
|
276 |
-
border: 1px solid var(--panel-border);
|
277 |
-
opacity: 0; /* For animation */
|
278 |
-
animation-duration: 0.35s;
|
279 |
-
animation-fill-mode: forwards;
|
280 |
-
}
|
281 |
-
.modal-overlay.visible .modal-dialog {
|
282 |
-
animation-name: modalZoomIn;
|
283 |
-
}
|
284 |
-
.modal-overlay.hiding .modal-dialog {
|
285 |
-
animation-name: modalZoomOut;
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--panel-border); }
|
290 |
-
.modal-header h2 { margin: 0; font-size: 1.6em; font-weight: 800; color: var(--accent-primary);}
|
291 |
-
.close-modal-btn { background: none; border: none; font-size: 2.5rem; cursor: pointer; color: var(--text-secondary); transition: var(--transition-smooth); line-height: 1; }
|
292 |
-
.close-modal-btn:hover { color: var(--accent-primary); transform: rotate(90deg) scale(1.1); }
|
293 |
-
|
294 |
-
|
295 |
-
/* --- مودال گالری گویندگان (اختصاصی) --- */
|
296 |
-
#speaker-modal .modal-dialog {
|
297 |
-
max-width: 700px;
|
298 |
-
max-height: 85vh; overflow-y: auto;
|
299 |
-
}
|
300 |
-
#speaker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1.2rem; }
|
301 |
-
@media (min-width: 640px) { #speaker-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); } }
|
302 |
-
.speaker-card { cursor: pointer; transition: var(--transition-smooth); text-align: center; position: relative;}
|
303 |
-
.speaker-card .speaker-visual {
|
304 |
-
border: 3px solid transparent;
|
305 |
-
border-radius: var(--radius-card);
|
306 |
-
overflow: hidden;
|
307 |
-
box-shadow: var(--shadow-subtle);
|
308 |
-
position: relative;
|
309 |
-
background-color: var(--input-bg);
|
310 |
-
transition: var(--transition-bounce);
|
311 |
-
padding: 6px;
|
312 |
-
}
|
313 |
-
.speaker-card:hover .speaker-visual {
|
314 |
-
transform: translateY(-5px) scale(1.06);
|
315 |
-
box-shadow: var(--shadow-medium);
|
316 |
-
}
|
317 |
-
.speaker-card input[type="radio"] { display: none; }
|
318 |
-
.speaker-card img {
|
319 |
-
width: 100%; height: 120px;
|
320 |
-
object-fit: cover; display: block;
|
321 |
-
background-color: #e0e0e0;
|
322 |
-
transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
323 |
-
border-radius: calc(var(--radius-card) - 12px);
|
324 |
-
}
|
325 |
-
.speaker-card:hover img { transform: scale(1.12); }
|
326 |
-
.speaker-card .speaker-name { padding: 0.8rem 0.4rem 0.1rem; font-weight: 600; font-size: 0.9em; color: var(--text-secondary); transition: color 0.2s; }
|
327 |
-
.speaker-card input[type="radio"]:checked + .speaker-visual {
|
328 |
-
border-color: var(--accent-secondary);
|
329 |
-
box-shadow: 0 0 25px -5px rgba(16, 185, 129, 0.75);
|
330 |
-
background: linear-gradient(135deg, var(--accent-secondary-hover), var(--accent-primary));
|
331 |
-
transform: scale(1.05);
|
332 |
-
}
|
333 |
-
.speaker-card input[type="radio"]:checked + .speaker-visual img {
|
334 |
-
border: 2px solid white;
|
335 |
-
transform: scale(1.05);
|
336 |
-
}
|
337 |
-
.speaker-card input[type="radio"]:checked + .speaker-visual .speaker-name {
|
338 |
-
color: #fff;
|
339 |
-
font-weight: 700;
|
340 |
-
}
|
341 |
-
|
342 |
-
/* --- مودال اطلاعات (اختصاصی) --- */
|
343 |
-
#info-modal .modal-dialog {
|
344 |
-
max-width: 480px; /* Smaller width for info */
|
345 |
-
}
|
346 |
-
#info-modal-content p {
|
347 |
-
font-size: 1em;
|
348 |
-
line-height: 1.7;
|
349 |
-
color: var(--text-secondary);
|
350 |
-
margin-bottom: 0.5rem;
|
351 |
-
}
|
352 |
-
#info-modal-content p strong {
|
353 |
-
color: var(--text-primary);
|
354 |
-
font-weight: 600;
|
355 |
-
}
|
356 |
-
#info-modal-content .range-info {
|
357 |
-
font-size: 0.9em;
|
358 |
-
color: var(--accent-primary);
|
359 |
-
font-weight: 500;
|
360 |
-
margin-top: 1rem;
|
361 |
-
display: block;
|
362 |
-
text-align: center;
|
363 |
-
}
|
364 |
-
|
365 |
-
|
366 |
-
/* --- Slider & Button & Output --- */
|
367 |
-
.slider-container { display: flex; align-items: center; gap: 1.2rem; }
|
368 |
-
input[type="range"] {
|
369 |
-
flex-grow: 1; -webkit-appearance: none; appearance: none;
|
370 |
-
width: 100%; height: 8px;
|
371 |
-
background: #EAF0F6;
|
372 |
-
border-radius: 4px; outline: none;
|
373 |
-
cursor: pointer;
|
374 |
-
transition: background 0.2s;
|
375 |
-
}
|
376 |
-
input[type="range"]::-webkit-slider-runnable-track {
|
377 |
-
background: linear-gradient(to right, var(--accent-secondary) 0%, var(--accent-primary) 100%);
|
378 |
-
height: 8px;
|
379 |
-
border-radius: 4px;
|
380 |
-
}
|
381 |
-
input[type="range"]::-webkit-slider-thumb {
|
382 |
-
-webkit-appearance: none; appearance: none;
|
383 |
-
width: 22px; height: 22px;
|
384 |
-
background: #fff;
|
385 |
-
border-radius: 50%; cursor: pointer;
|
386 |
-
border: 3px solid var(--accent-primary);
|
387 |
-
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
|
388 |
-
margin-top: -7px;
|
389 |
-
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
390 |
-
}
|
391 |
-
input[type="range"]::-webkit-slider-thumb:hover, input[type="range"]:focus::-webkit-slider-thumb {
|
392 |
-
transform: scale(1.2);
|
393 |
-
box-shadow: 0 3px 8px rgba(59, 130, 246, 0.35);
|
394 |
-
}
|
395 |
-
input[type="range"]::-moz-range-thumb {
|
396 |
-
width: 22px; height: 22px;
|
397 |
-
background: #fff;
|
398 |
-
border-radius: 50%; cursor: pointer;
|
399 |
-
border: 3px solid var(--accent-primary);
|
400 |
-
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
|
401 |
-
}
|
402 |
-
input[type="range"]::-moz-range-track {
|
403 |
-
background: linear-gradient(to right, var(--accent-secondary) 0%, var(--accent-primary) 100%);
|
404 |
-
height: 8px;
|
405 |
-
border-radius: 4px;
|
406 |
-
border: none;
|
407 |
-
}
|
408 |
-
#temperature-value {
|
409 |
-
font-weight: 700; background-color: var(--input-bg);
|
410 |
-
padding: 0.5rem 1rem;
|
411 |
-
border-radius: 8px;
|
412 |
-
border: 1px solid var(--panel-border);
|
413 |
-
min-width: 45px; text-align: center;
|
414 |
-
color: var(--accent-primary);
|
415 |
-
font-size: 1em;
|
416 |
-
box-shadow: var(--shadow-subtle);
|
417 |
-
}
|
418 |
-
|
419 |
-
#generate-btn {
|
420 |
-
width: 100%; padding: 1rem 1.5rem;
|
421 |
-
font-size: 1.25em; font-weight: 800;
|
422 |
-
font-family: var(--app-font);
|
423 |
-
background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
|
424 |
-
color: #fff;
|
425 |
-
border: none;
|
426 |
-
border-radius: var(--radius-input);
|
427 |
-
cursor: pointer;
|
428 |
-
transition: var(--transition-smooth), transform 0.15s ease-out;
|
429 |
-
box-shadow: 0 5px 15px -4px rgba(59, 130, 246, 0.45), 0 5px 15px -4px rgba(16, 185, 129, 0.35);
|
430 |
-
position: relative;
|
431 |
-
overflow: hidden;
|
432 |
-
letter-spacing: 0.5px;
|
433 |
-
}
|
434 |
-
#generate-btn::before {
|
435 |
-
content: ''; position: absolute;
|
436 |
-
top: 0; left: -180%; width: 80%; height: 100%;
|
437 |
-
background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.25) 50%, rgba(255,255,255,0) 100%);
|
438 |
-
transform: skewX(-30deg);
|
439 |
-
transition: left 0.8s cubic-bezier(0.23, 1, 0.32, 1);
|
440 |
-
}
|
441 |
-
#generate-btn:hover::before { left: 180%; }
|
442 |
-
#generate-btn:hover:not(:disabled) {
|
443 |
-
transform: translateY(-5px) scale(1.02);
|
444 |
-
box-shadow: 0 8px 20px -4px rgba(59, 130, 246, 0.55), 0 8px 20px -4px rgba(16, 185, 129, 0.45);
|
445 |
-
}
|
446 |
-
#generate-btn:active:not(:disabled) {
|
447 |
-
transform: translateY(-2px) scale(0.98);
|
448 |
-
}
|
449 |
-
#generate-btn:disabled {
|
450 |
-
background: #B8C2CC;
|
451 |
-
cursor: not-allowed; box-shadow: none; color: #E8EEF3;
|
452 |
-
transform: none;
|
453 |
-
}
|
454 |
-
#generate-btn:disabled::before { display: none; }
|
455 |
-
#generate-btn svg {
|
456 |
-
display:inline-block; margin-left: 0.5em; width:1.2em; height:1.2em;
|
457 |
-
vertical-align: middle;
|
458 |
}
|
459 |
|
460 |
-
/* --- Output Section (now the card container for status/loading/player) --- */
|
461 |
#output-section {
|
462 |
margin-top: 3rem;
|
463 |
display: flex;
|
@@ -486,10 +95,13 @@
|
|
486 |
display: none !important;
|
487 |
}
|
488 |
|
489 |
-
#status-message {
|
490 |
-
|
|
|
|
|
|
|
|
|
491 |
|
492 |
-
/* --- انیمیشن پردازش --- */
|
493 |
#loading-animation-wrapper {
|
494 |
display: none;
|
495 |
flex-direction: column;
|
@@ -498,57 +110,6 @@
|
|
498 |
gap: 1.8rem;
|
499 |
width: 100%;
|
500 |
}
|
501 |
-
.orbital-loader {
|
502 |
-
width: 110px;
|
503 |
-
height: 110px;
|
504 |
-
position: relative;
|
505 |
-
animation: rotate-loader-orbital 10s linear infinite;
|
506 |
-
}
|
507 |
-
.orbit {
|
508 |
-
position: absolute;
|
509 |
-
top: 50%; left: 50%;
|
510 |
-
border: 2px dashed rgba(59, 130, 246, 0.25);
|
511 |
-
border-radius: 50%;
|
512 |
-
transform-origin: center center;
|
513 |
-
}
|
514 |
-
.orbit:nth-child(1) { width: 35px; height: 35px; margin: -17.5px 0 0 -17.5px; animation: orbit-spin 2.8s linear infinite reverse; }
|
515 |
-
.orbit:nth-child(2) { width: 65px; height: 65px; margin: -32.5px 0 0 -32.5px; animation: orbit-spin 3.8s linear infinite; }
|
516 |
-
.orbit:nth-child(3) { width: 95px; height: 95px; margin: -47.5px 0 0 -47.5px; animation: orbit-spin 4.8s linear infinite reverse; }
|
517 |
-
|
518 |
-
.orbit .satellite {
|
519 |
-
position: absolute;
|
520 |
-
width: 10px; height: 10px;
|
521 |
-
border-radius: 50%;
|
522 |
-
background-color: var(--accent-primary);
|
523 |
-
box-shadow: 0 0 8px var(--accent-primary), 0 0 12px var(--accent-secondary);
|
524 |
-
}
|
525 |
-
.orbit:nth-child(1) .satellite { top: -5px; left: 50%; animation: satellite-pulse-1 1.4s ease-in-out infinite alternate; }
|
526 |
-
.orbit:nth-child(2) .satellite { top: 50%; left: -5px; background-color: var(--accent-secondary); animation: satellite-pulse-2 1.4s 0.2s ease-in-out infinite alternate; }
|
527 |
-
.orbit:nth-child(3) .satellite { bottom: -5px; right: 50%; animation: satellite-pulse-3 1.4s 0.4s ease-in-out infinite alternate;}
|
528 |
-
|
529 |
-
@keyframes rotate-loader-orbital { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
530 |
-
@keyframes orbit-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
531 |
-
@keyframes satellite-pulse-1 {
|
532 |
-
from { transform: scale(0.7) translateX(-50%); opacity: 0.6; }
|
533 |
-
to { transform: scale(1.1) translateX(-50%); opacity: 1; }
|
534 |
-
}
|
535 |
-
@keyframes satellite-pulse-2 {
|
536 |
-
from { transform: scale(0.7) translateY(-50%); opacity: 0.6; }
|
537 |
-
to { transform: scale(1.1) translateY(-50%); opacity: 1; }
|
538 |
-
}
|
539 |
-
@keyframes satellite-pulse-3 {
|
540 |
-
from { transform: scale(0.7) translateX(50%); opacity: 0.6; }
|
541 |
-
to { transform: scale(1.1) translateX(50%); opacity: 1; }
|
542 |
-
}
|
543 |
-
#loading-text {
|
544 |
-
font-size: 1.2em;
|
545 |
-
font-weight: 700;
|
546 |
-
color: var(--text-primary);
|
547 |
-
text-align: center;
|
548 |
-
background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
|
549 |
-
-webkit-background-clip: text;
|
550 |
-
-webkit-text-fill-color: transparent;
|
551 |
-
}
|
552 |
|
553 |
/* --- Custom Audio Player Styles --- */
|
554 |
#audio-player-content {
|
@@ -575,44 +136,21 @@
|
|
575 |
font-variant-numeric: tabular-nums;
|
576 |
}
|
577 |
|
578 |
-
/* Waveform Display */
|
579 |
.audio-waveform {
|
580 |
flex-grow: 1;
|
581 |
height: 60px;
|
582 |
position: relative;
|
583 |
-
|
584 |
}
|
585 |
-
|
586 |
position: absolute;
|
587 |
top: 0;
|
588 |
left: 0;
|
589 |
width: 100%;
|
590 |
height: 100%;
|
591 |
-
display: flex;
|
592 |
-
justify-content: space-between;
|
593 |
-
align-items: center;
|
594 |
-
z-index: 0;
|
595 |
-
}
|
596 |
-
.waveform-bar {
|
597 |
-
width: 3px;
|
598 |
-
background-color: var(--waveform-color-inactive);
|
599 |
-
border-radius: 2px;
|
600 |
-
flex-shrink: 0;
|
601 |
-
margin: 0 1px;
|
602 |
-
}
|
603 |
-
.audio-waveform-dashed-line {
|
604 |
-
position: absolute;
|
605 |
-
top: 50%;
|
606 |
-
left: 0;
|
607 |
-
width: 100%;
|
608 |
-
height: 1px;
|
609 |
-
background-image: linear-gradient(to right, var(--waveform-dashed-line-color) 33%, transparent 0%);
|
610 |
-
background-position: center;
|
611 |
-
background-size: 10px 1px;
|
612 |
-
transform: translateY(-50%);
|
613 |
-
z-index: 1;
|
614 |
}
|
615 |
-
|
616 |
/* Audio Controls */
|
617 |
.audio-controls-group {
|
618 |
display: flex;
|
@@ -637,21 +175,9 @@
|
|
637 |
.audio-skip-btn:active, .audio-play-pause-btn-large:active, .audio-volume-btn:active {
|
638 |
transform: scale(0.9);
|
639 |
}
|
640 |
-
.audio-skip-btn svg {
|
641 |
-
|
642 |
-
|
643 |
-
fill: currentColor;
|
644 |
-
}
|
645 |
-
.audio-play-pause-btn-large {
|
646 |
-
padding: 0;
|
647 |
-
width: 50px;
|
648 |
-
height: 50px;
|
649 |
-
}
|
650 |
-
.audio-play-pause-btn-large svg {
|
651 |
-
width: 38px;
|
652 |
-
height: 38px;
|
653 |
-
fill: currentColor;
|
654 |
-
}
|
655 |
|
656 |
.audio-utility-controls {
|
657 |
display: flex;
|
@@ -659,11 +185,7 @@
|
|
659 |
justify-content: space-between;
|
660 |
width: 100%;
|
661 |
}
|
662 |
-
.audio-volume-btn svg {
|
663 |
-
width: 24px;
|
664 |
-
height: 24px;
|
665 |
-
fill: currentColor;
|
666 |
-
}
|
667 |
.audio-speed-btn {
|
668 |
font-family: var(--app-font);
|
669 |
font-size: 0.9em;
|
@@ -676,118 +198,41 @@
|
|
676 |
color: var(--text-primary);
|
677 |
box-shadow: var(--shadow-subtle);
|
678 |
}
|
679 |
-
.audio-speed-btn:hover {
|
680 |
-
background-color: var(--input-bg);
|
681 |
-
}
|
682 |
|
683 |
-
/* Hide the default audio player */
|
684 |
#hidden-audio-player { display: none !important; }
|
685 |
|
686 |
-
/* Responsive adjustments for mobile */
|
687 |
@media (max-width: 600px) {
|
688 |
-
.
|
689 |
-
|
690 |
-
}
|
691 |
-
.
|
692 |
-
|
693 |
-
}
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
#audio-player-content {
|
698 |
-
padding: 1rem;
|
699 |
-
}
|
700 |
-
.audio-controls-group {
|
701 |
-
gap: 1rem; /* Reduce gap between play/skip */
|
702 |
-
}
|
703 |
-
.audio-skip-btn svg {
|
704 |
-
width: 24px;
|
705 |
-
height: 24px;
|
706 |
-
}
|
707 |
-
.audio-play-pause-btn-large {
|
708 |
-
width: 44px;
|
709 |
-
height: 44px;
|
710 |
-
}
|
711 |
-
.audio-play-pause-btn-large svg {
|
712 |
-
width: 32px;
|
713 |
-
height: 32px;
|
714 |
-
}
|
715 |
-
}
|
716 |
</style>
|
717 |
</head>
|
718 |
<body>
|
719 |
<div class="container">
|
720 |
-
|
721 |
-
<h1>تبدیل متن به صدا با هوش مصنوعی آلفا</h1>
|
722 |
-
<p>صدایی نو، تجربهای نوین در تبدیل متن به گفتار با هوش مصنوعی پیشرفته</p>
|
723 |
-
</header>
|
724 |
-
|
725 |
<main class="main-content">
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
<div class="char-counter-wrapper">
|
731 |
-
<span id="char-count">0</span> / <span id="char-max">50000</span> نویسه
|
732 |
-
</div>
|
733 |
-
</div>
|
734 |
-
<div class="form-group">
|
735 |
-
<label for="prompt-input">🗣️ توصیف سبک و لحن گفتار (اختیاری)</label>
|
736 |
-
<input type="text" id="prompt-input" placeholder="مثال: با لحنی رسمی و موقر، یا شاد و کودکانه">
|
737 |
-
</div>
|
738 |
-
|
739 |
-
<div class="form-group">
|
740 |
-
<label>🎤 انتخاب گوینده حرفهای</label>
|
741 |
-
<div id="selected-speaker-display">
|
742 |
-
<div id="selected-speaker-card" title="برای تغییر گوینده کلیک کنید">
|
743 |
-
<img id="selected-speaker-img" src="" alt="عکس گوینده">
|
744 |
-
<div id="selected-speaker-info">
|
745 |
-
<h3 id="selected-speaker-name"></h3>
|
746 |
-
<p id="selected-speaker-desc">گوینده پیشفرض</p>
|
747 |
-
</div>
|
748 |
-
</div>
|
749 |
-
<button type="button" id="change-speaker-btn">
|
750 |
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
751 |
-
<path d="M12 2.5a5.5 5.5 0 0 1 5.5 5.5c0 1.826-.889 3.442-2.257 4.494.04.054.082.106.126.158A7.5 7.5 0 0 1 21.75 18H2.25a7.5 7.5 0 0 1 6.381-5.348c.044-.052.087-.104.127-.158A5.502 5.502 0 0 1 6.5 8a5.5 5.5 0 0 1 5.5-5.5Zm3.018 9.589A7.502 7.502 0 0 0 12 11.5a7.502 7.502 0 0 0-3.018.589C6.44 12.51 5.018 13.56 4.135 14.997a.75.75 0 0 0 .614.853A10.51 10.51 0 0 0 12 16.5a10.51 10.51 0 0 0 7.251-.65.75.75 0 0 0 .614-.853 9.998 9.998 0 0 0-4.847-2.408Z" />
|
752 |
-
</svg>
|
753 |
-
تغییر گوینده
|
754 |
-
</button>
|
755 |
-
</div>
|
756 |
-
</div>
|
757 |
-
|
758 |
-
<div class="form-group">
|
759 |
-
<div class="label-with-info">
|
760 |
-
<label for="temperature-slider">🌡️ میزان خلاقیت و نوآوری صدا</label>
|
761 |
-
<div class="info-icon" id="temp-info-icon" role="button" tabindex="0" aria-label="اطلاعات بیشتر">!
|
762 |
-
</div>
|
763 |
-
</div>
|
764 |
-
<div class="slider-container">
|
765 |
-
<input type="range" id="temperature-slider" min="0.1" max="1.5" step="0.05" value="0.9">
|
766 |
-
<span id="temperature-value">0.9</span>
|
767 |
-
</div>
|
768 |
-
</div>
|
769 |
-
|
770 |
-
<button type="submit" id="generate-btn">✨ تولید صدا با آلفا</button>
|
771 |
-
</form>
|
772 |
|
773 |
<div id="output-section">
|
774 |
<div id="status-message">صدای تولید شده در اینجا نمایش داده خواهد شد.</div>
|
775 |
-
<div id="loading-animation-wrapper">
|
776 |
-
<div class="orbital-loader">
|
777 |
-
<div class="orbit"><div class="satellite"></div></div>
|
778 |
-
<div class="orbit"><div class="satellite"></div></div>
|
779 |
-
<div class="orbit"><div class="satellite"></div></div>
|
780 |
-
</div>
|
781 |
-
<p id="loading-text">در حال پردازش هوشمند و تولید صدا...</p>
|
782 |
-
</div>
|
783 |
|
784 |
<!-- Custom Audio Player Structure -->
|
785 |
<div id="audio-player-content">
|
786 |
<div class="audio-waveform-container">
|
787 |
<span class="audio-time audio-current-time">0:00</span>
|
788 |
<div class="audio-waveform">
|
789 |
-
<
|
790 |
-
<div class="audio-waveform-dashed-line"></div>
|
791 |
</div>
|
792 |
<span class="audio-time audio-total-time">0:00</span>
|
793 |
</div>
|
@@ -813,114 +258,22 @@
|
|
813 |
<button class="audio-speed-btn">1x</button>
|
814 |
</div>
|
815 |
</div>
|
816 |
-
<audio id="hidden-audio-player"
|
817 |
</div>
|
818 |
</main>
|
819 |
</div>
|
820 |
|
821 |
-
<!-- مودال گالری گویندگان -->
|
822 |
-
<div id="speaker-modal" class="modal-overlay">
|
823 |
-
<div class="modal-dialog">
|
824 |
-
<div class="modal-header">
|
825 |
-
<h2>گالری گویندگان آلفا نوا</h2>
|
826 |
-
<button type="button" class="close-modal-btn" data-modal-id="speaker-modal" aria-label="بستن مودال">×</button>
|
827 |
-
</div>
|
828 |
-
<div id="speaker-grid">
|
829 |
-
<!-- Speaker cards will be generated here by JS -->
|
830 |
-
</div>
|
831 |
-
</div>
|
832 |
-
</div>
|
833 |
-
|
834 |
-
<!-- مودال اطلاعات خلاقیت صدا -->
|
835 |
-
<div id="info-modal" class="modal-overlay">
|
836 |
-
<div class="modal-dialog">
|
837 |
-
<div class="modal-header">
|
838 |
-
<h2>🌡️ خلاقیت و نوآوری صدا</h2>
|
839 |
-
<button type="button" class="close-modal-btn" data-modal-id="info-modal" aria-label="بستن توضیحات">×</button>
|
840 |
-
</div>
|
841 |
-
<div id="info-modal-content">
|
842 |
-
<p>این تنظیم مشخص میکند که هوش مصنوعی تا چه حد در تولید صدا <strong>خلاقیت</strong> به خرج دهد.</p>
|
843 |
-
<p><strong>مقادیر بالاتر:</strong> منجر به صدایی متنوعتر، پویاتر و گاهی اوقات غیرمنتظرهتر میشود. مناسب برای زمانی که به دنبال لحنی خاص و منحصربهفرد هستید.</p>
|
844 |
-
<p><strong>مقادیر پایینتر:</strong> صدایی پایدارتر، قابل پیشبینیتر و نزدیکتر به صدای استاندارد گوینده تولید میکند. مناسب برای خوانش متون رسمی یا زمانی که ثبات لحن اهمیت دارد.</p>
|
845 |
-
<span class="range-info">محدوده پیشنهادی: ۰.۱ (پایدار) تا ۱.۵ (بسیار خلاق)</span>
|
846 |
-
</div>
|
847 |
-
</div>
|
848 |
-
</div>
|
849 |
-
|
850 |
-
|
851 |
-
<input type="hidden" id="selected_speaker_id_storage" value="Charon">
|
852 |
-
|
853 |
<script>
|
854 |
document.addEventListener('DOMContentLoaded', () => {
|
855 |
-
|
856 |
-
const JOIN_QUEUE_URL = `${HF_SPACE_URL}/gradio_api/queue/join`;
|
857 |
-
const GET_DATA_URL_BASE = `${HF_SPACE_URL}/gradio_api/queue/data`;
|
858 |
-
const FILE_URL_BASE = `${HF_SPACE_URL}/gradio_api/file=`;
|
859 |
-
const FN_INDEX = 1;
|
860 |
-
|
861 |
-
const speakers = [
|
862 |
-
{ id: "Charon", name: "شهاب (مرد)", desc: "صدایی قدرتمند و رسا" },
|
863 |
-
{ id: "Zephyr", name: "آوا (زن)", desc: "لطیف و دلنشین" },
|
864 |
-
{ id: "Achird", name: "نوید (مرد)", desc: "جوان و پرانرژی" },
|
865 |
-
{ id: "Zubenelgenubi", name: "رویا (زن)", desc: "گرم و صمیمی" },
|
866 |
-
{ id: "Vindemiatrix", name: "کیان (مرد)", desc: "باوقار و رسمی" },
|
867 |
-
{ id: "Sadachbia", name: "پریسا (زن)", desc: "شاداب و پویا" },
|
868 |
-
{ id: "Sadaltager", name: "آرش (مرد)", desc: "مطمئن و تاثیرگذار" },
|
869 |
-
{ id: "Sulafat", name: "شبنم (زن)", desc: "آرام و متین" },
|
870 |
-
{ id: "Laomedeia", name: "سهیل (مرد)", desc: "دوستانه و گیرا" },
|
871 |
-
{ id: "Achernar", name: "مریم (زن)", desc: "حرفهای و واضح" },
|
872 |
-
{ id: "Alnilam", name: "بهرام (مرد)", desc: "حماسی و نافذ" },
|
873 |
-
{ id: "Schedar", name: "نگار (زن)", desc: "مهربان و شیرین" },
|
874 |
-
{ id: "Gacrux", name: "فرید (مرد)", desc: "پخته و قابل اعت��اد" },
|
875 |
-
{ id: "Pulcherrima", name: "سارا (زن)", desc: "جذاب و مدرن" },
|
876 |
-
{ id: "Umbriel", name: "مانی (مرد)", desc: "خلاق و متفاوت" },
|
877 |
-
{ id: "Algieba", name: "آناهیتا (زن)", desc: "با اصالت و شیک" },
|
878 |
-
{ id: "Despina", name: "دلنواز (زن)", desc: "هنری و احساسی" },
|
879 |
-
{ id: "Erinome", name: "رسا (مرد)", desc: "شفاف و گویا" },
|
880 |
-
{ id: "Algenib", name: "امید (مرد)", desc: "انگیزه بخش و مثبت" },
|
881 |
-
{ id: "Rasalthgeti", name: "الهه (زن)", desc: "اسرارآمیز و فریبنده" },
|
882 |
-
{ id: "Orus", name: "بردیا (مرد)", desc: "ورزشی و پرهیجان" },
|
883 |
-
{ id: "Aoede", name: "ترانه (زن)", desc: "موزیکال و خوشآهنگ" },
|
884 |
-
{ id: "Callirrhoe", name: "نیما (مرد)", desc: "روایتگر و قصهگو" },
|
885 |
-
{ id: "Autonoe", name: "هستی (زن)", "desc": "طبیعی و خودمانی" },
|
886 |
-
{ id: "Enceladus", name: "کامیار (مرد)", desc: "مصمم و جدی" },
|
887 |
-
{ id: "Iapetus", name: "ستاره (زن)", desc: "درخشان و گیرا" },
|
888 |
-
{ id: "Puck", name: "پویا (مرد)", desc: "بازیگوش و سرزنده" },
|
889 |
-
{ id: "Kore", name: "مهتاب (زن)", desc: "نجواگر و آرامشبخش" },
|
890 |
-
{ id: "Fenrir", name: "سام (مرد)", desc: "جسور و بیباک" },
|
891 |
-
{ id: "Leda", name: "لیدا (زن)", desc: "کلاسیک و باوقار" }
|
892 |
-
];
|
893 |
-
|
894 |
-
const form = document.getElementById('tts-form');
|
895 |
-
const textInput = document.getElementById('text-input');
|
896 |
-
const promptInput = document.getElementById('prompt-input');
|
897 |
-
const tempSlider = document.getElementById('temperature-slider');
|
898 |
-
const tempValueSpan = document.getElementById('temperature-value');
|
899 |
-
const generateBtn = document.getElementById('generate-btn');
|
900 |
-
|
901 |
-
const outputSection = document.getElementById('output-section');
|
902 |
-
const statusMessage = document.getElementById('status-message');
|
903 |
-
const loadingAnimationWrapper = document.getElementById('loading-animation-wrapper');
|
904 |
-
|
905 |
-
const selectedSpeakerIdStorage = document.getElementById('selected_speaker_id_storage');
|
906 |
-
const changeSpeakerBtn = document.getElementById('change-speaker-btn');
|
907 |
-
const selectedSpeakerCard = document.getElementById('selected-speaker-card');
|
908 |
-
const speakerGridInModal = document.getElementById('speaker-grid');
|
909 |
-
const selectedSpeakerImgDisplay = document.getElementById('selected-speaker-img');
|
910 |
-
const selectedSpeakerNameDisplay = document.getElementById('selected-speaker-name');
|
911 |
-
const selectedSpeakerDescDisplay = document.getElementById('selected-speaker-desc');
|
912 |
-
|
913 |
-
// Modal Elements
|
914 |
-
const speakerModal = document.getElementById('speaker-modal');
|
915 |
-
const infoModal = document.getElementById('info-modal');
|
916 |
-
const tempInfoIcon = document.getElementById('temp-info-icon');
|
917 |
-
|
918 |
-
// --- Custom Audio Player Elements ---
|
919 |
const hiddenAudioPlayer = document.getElementById('hidden-audio-player');
|
920 |
const audioPlayerContent = document.getElementById('audio-player-content');
|
|
|
|
|
|
|
|
|
921 |
const audioCurrentTimeSpan = audioPlayerContent.querySelector('.audio-current-time');
|
922 |
const audioTotalTimeSpan = audioPlayerContent.querySelector('.audio-total-time');
|
923 |
-
const audioWaveformBarsWrapper = audioPlayerContent.querySelector('.audio-waveform-bars-wrapper');
|
924 |
const playPauseBtn = audioPlayerContent.querySelector('.audio-play-pause-btn-large');
|
925 |
const playIcon = playPauseBtn.querySelector('.play-icon');
|
926 |
const pauseIcon = playPauseBtn.querySelector('.pause-icon');
|
@@ -931,159 +284,98 @@
|
|
931 |
const volumeMuteIcon = volumeBtn.querySelector('.volume-mute-icon');
|
932 |
const speedBtn = audioPlayerContent.querySelector('.audio-speed-btn');
|
933 |
|
934 |
-
let
|
935 |
-
|
936 |
|
937 |
-
//
|
938 |
-
const charCountSpan = document.getElementById('char-count');
|
939 |
-
const charMaxSpan = document.getElementById('char-max');
|
940 |
-
const MAX_CHARS = 50000;
|
941 |
-
charMaxSpan.textContent = MAX_CHARS.toLocaleString('fa-IR');
|
942 |
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
charCountSpan.style.color = 'var(--accent-secondary-hover)';
|
948 |
-
} else {
|
949 |
-
charCountSpan.style.color = 'var(--accent-primary)';
|
950 |
}
|
951 |
-
});
|
952 |
-
|
953 |
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
const imageIndex = (imageSeed * 7 + 5) % 100;
|
962 |
-
let portraitSizePath = 'thumb/';
|
963 |
-
if (size === 'large') portraitSizePath = '';
|
964 |
-
return `https://randomuser.me/api/portraits/${portraitSizePath}${gender}/${imageIndex}.jpg`;
|
965 |
-
}
|
966 |
-
|
967 |
-
function updateSelectedSpeakerDisplay(speakerId) {
|
968 |
-
const speaker = getSpeakerById(speakerId);
|
969 |
-
const speakerIndex = speakers.findIndex(s => s.id === speaker.id);
|
970 |
-
selectedSpeakerImgDisplay.src = getImageUrl(speaker, speakerIndex, 'large');
|
971 |
-
selectedSpeakerImgDisplay.alt = `عکس گوینده ${speaker.name}`;
|
972 |
-
selectedSpeakerNameDisplay.textContent = speaker.name;
|
973 |
-
selectedSpeakerDescDisplay.textContent = speaker.desc || "گوینده منتخب شما";
|
974 |
-
selectedSpeakerIdStorage.value = speaker.id;
|
975 |
-
}
|
976 |
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
const cardLabel = document.createElement('label');
|
981 |
-
cardLabel.className = 'speaker-card';
|
982 |
-
cardLabel.setAttribute('for', `modal-speaker-${speaker.id}`);
|
983 |
-
const isChecked = speaker.id === selectedSpeakerIdStorage.value ? 'checked' : '';
|
984 |
-
cardLabel.innerHTML = `
|
985 |
-
<input type="radio" name="modal_speaker_selection" value="${speaker.id}" id="modal-speaker-${speaker.id}" ${isChecked}>
|
986 |
-
<div class="speaker-visual">
|
987 |
-
<img src="${getImageUrl(speaker, index, 'thumb')}" alt="${speaker.name}" loading="lazy">
|
988 |
-
<div class="speaker-name">${speaker.name}</div>
|
989 |
-
</div>
|
990 |
-
`;
|
991 |
-
cardLabel.addEventListener('click', (e) => {
|
992 |
-
if (e.target.name !== "modal_speaker_selection") {
|
993 |
-
const radio = cardLabel.querySelector('input[type="radio"]');
|
994 |
-
if(radio) radio.checked = true;
|
995 |
-
}
|
996 |
-
updateSelectedSpeakerDisplay(speaker.id);
|
997 |
-
hideModal(speakerModal);
|
998 |
-
});
|
999 |
-
speakerGridInModal.appendChild(cardLabel);
|
1000 |
-
});
|
1001 |
-
}
|
1002 |
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
}
|
1010 |
}
|
1011 |
|
1012 |
-
function
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1018 |
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
selectedSpeakerCard.addEventListener('click', () => {
|
1025 |
-
createSpeakerCardsInModal();
|
1026 |
-
showModal(speakerModal);
|
1027 |
-
});
|
1028 |
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
|
|
1035 |
}
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
}
|
1045 |
-
});
|
1046 |
-
});
|
1047 |
-
document.querySelectorAll('.close-modal-btn').forEach(button => {
|
1048 |
-
button.addEventListener('click', () => {
|
1049 |
-
const modalId = button.dataset.modalId;
|
1050 |
-
if (modalId) {
|
1051 |
-
hideModal(document.getElementById(modalId));
|
1052 |
-
}
|
1053 |
-
});
|
1054 |
-
});
|
1055 |
-
document.addEventListener('keydown', (e) => {
|
1056 |
-
if (e.key === 'Escape') {
|
1057 |
-
document.querySelectorAll('.modal-overlay.visible').forEach(hideModal);
|
1058 |
}
|
1059 |
-
});
|
1060 |
-
|
1061 |
-
|
1062 |
-
tempSlider.addEventListener('input', () => { tempValueSpan.textContent = tempSlider.value; });
|
1063 |
-
|
1064 |
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
const barWidth = 3; // From CSS
|
1074 |
-
const barMargin = 1; // From CSS
|
1075 |
-
const totalBarWidth = barWidth + (barMargin * 2);
|
1076 |
-
const numBars = Math.floor(containerWidth / totalBarWidth);
|
1077 |
-
|
1078 |
-
for (let i = 0; i < numBars; i++) {
|
1079 |
-
const bar = document.createElement('div');
|
1080 |
-
bar.classList.add('waveform-bar');
|
1081 |
-
// Simple randomized heights for visual variety
|
1082 |
-
const height = Math.random() * 90 + 10; // Height between 10% and 100%
|
1083 |
-
bar.style.height = `${height}%`;
|
1084 |
-
audioWaveformBarsWrapper.appendChild(bar);
|
1085 |
-
}
|
1086 |
}
|
|
|
|
|
1087 |
|
1088 |
function formatTime(seconds) {
|
1089 |
if (isNaN(seconds) || seconds < 0) return '0:00';
|
@@ -1092,229 +384,76 @@
|
|
1092 |
return `${minutes}:${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`;
|
1093 |
}
|
1094 |
|
1095 |
-
// Update custom player UI
|
1096 |
function updatePlayerUI() {
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
pauseIcon.style.display = 'block';
|
1103 |
-
}
|
1104 |
-
|
1105 |
const currentTime = hiddenAudioPlayer.currentTime;
|
1106 |
const duration = hiddenAudioPlayer.duration;
|
1107 |
audioCurrentTimeSpan.textContent = formatTime(currentTime);
|
1108 |
|
1109 |
if (isFinite(duration) && duration > 0) {
|
1110 |
audioTotalTimeSpan.textContent = formatTime(duration);
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
const barsToColor = Math.floor(progressRatio * numBars);
|
1115 |
-
|
1116 |
-
for (let i = 0; i < numBars; i++) {
|
1117 |
-
if (i < barsToColor) {
|
1118 |
-
bars[i].style.backgroundColor = 'var(--waveform-color-active)';
|
1119 |
-
} else {
|
1120 |
-
bars[i].style.backgroundColor = 'var(--waveform-color-inactive)';
|
1121 |
-
}
|
1122 |
}
|
1123 |
} else {
|
1124 |
audioTotalTimeSpan.textContent = '0:00';
|
1125 |
-
const bars = audioWaveformBarsWrapper.children;
|
1126 |
-
for (let i = 0; i < bars.length; i++) {
|
1127 |
-
bars[i].style.backgroundColor = 'var(--waveform-color-inactive)';
|
1128 |
-
}
|
1129 |
}
|
1130 |
}
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
skipBackwardBtn.addEventListener('click', () => {
|
1140 |
-
hiddenAudioPlayer.currentTime = Math.max(0, hiddenAudioPlayer.currentTime - 5); // Skip 5 seconds back
|
1141 |
-
});
|
1142 |
-
skipForwardBtn.addEventListener('click', () => {
|
1143 |
-
hiddenAudioPlayer.currentTime = Math.min(hiddenAudioPlayer.duration, hiddenAudioPlayer.currentTime + 5); // Skip 5 seconds forward
|
1144 |
-
});
|
1145 |
-
volumeBtn.addEventListener('click', () => {
|
1146 |
-
hiddenAudioPlayer.muted = !hiddenAudioPlayer.muted;
|
1147 |
-
volumeHighIcon.style.display = hiddenAudioPlayer.muted ? 'none' : 'block';
|
1148 |
-
volumeMuteIcon.style.display = hiddenAudioPlayer.muted ? 'block' : 'none';
|
1149 |
-
});
|
1150 |
-
speedBtn.addEventListener('click', () => {
|
1151 |
-
currentPlaybackSpeedIndex = (currentPlaybackSpeedIndex + 1) % playbackSpeeds.length;
|
1152 |
-
const newSpeed = playbackSpeeds[currentPlaybackSpeedIndex];
|
1153 |
-
hiddenAudioPlayer.playbackRate = newSpeed;
|
1154 |
-
speedBtn.textContent = `${newSpeed}x`;
|
1155 |
});
|
1156 |
|
1157 |
-
hiddenAudioPlayer.addEventListener('timeupdate', updatePlayerUI);
|
1158 |
-
hiddenAudioPlayer.addEventListener('loadedmetadata', () => {
|
1159 |
-
generateWaveformBars();
|
1160 |
-
updatePlayerUI();
|
1161 |
-
});
|
1162 |
-
hiddenAudioPlayer.addEventListener('play', updatePlayerUI);
|
1163 |
-
hiddenAudioPlayer.addEventListener('pause', updatePlayerUI);
|
1164 |
-
hiddenAudioPlayer.addEventListener('ended', () => {
|
1165 |
-
hiddenAudioPlayer.currentTime = 0;
|
1166 |
-
updatePlayerUI();
|
1167 |
-
});
|
1168 |
-
|
1169 |
-
let resizeTimeout;
|
1170 |
-
window.addEventListener('resize', () => {
|
1171 |
-
clearTimeout(resizeTimeout);
|
1172 |
-
resizeTimeout = setTimeout(() => {
|
1173 |
-
if (outputSection.classList.contains('has-content')) {
|
1174 |
-
generateWaveformBars();
|
1175 |
-
updatePlayerUI();
|
1176 |
-
}
|
1177 |
-
}, 250);
|
1178 |
-
});
|
1179 |
|
|
|
|
|
|
|
|
|
1180 |
|
1181 |
-
// --- State Management Functions ---
|
1182 |
-
function showLoadingState() {
|
1183 |
-
audioPlayerContent.style.display = 'none';
|
1184 |
-
outputSection.classList.remove('has-content');
|
1185 |
-
statusMessage.style.display = 'block'; // Show status temporarily if needed
|
1186 |
-
loadingAnimationWrapper.style.display = 'flex';
|
1187 |
-
generateBtn.disabled = true;
|
1188 |
-
generateBtn.innerHTML = `
|
1189 |
-
<svg aria-hidden="true" role="status" fill="currentColor" viewBox="0 0 100 101" style="display:inline-block; margin-left: 0.5em; width:1.2em; height:1.2em; vertical-align: middle; animation: spin 1s linear infinite;">
|
1190 |
-
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="#E5E7EB"/>
|
1191 |
-
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0492C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentColor"/>
|
1192 |
-
</svg>
|
1193 |
-
در حال پردازش...
|
1194 |
-
`;
|
1195 |
-
}
|
1196 |
-
|
1197 |
-
function showResultState(isSuccess, message = '') {
|
1198 |
loadingAnimationWrapper.style.display = 'none';
|
1199 |
-
if (isSuccess) {
|
1200 |
statusMessage.style.display = 'none';
|
1201 |
audioPlayerContent.style.display = 'flex';
|
1202 |
outputSection.classList.add('has-content');
|
|
|
|
|
|
|
|
|
1203 |
hiddenAudioPlayer.play();
|
1204 |
} else {
|
1205 |
-
|
1206 |
-
statusMessage.style.display = 'block';
|
1207 |
-
audioPlayerContent.style.display = 'none';
|
1208 |
-
outputSection.classList.remove('has-content');
|
1209 |
-
hiddenAudioPlayer.pause();
|
1210 |
-
hiddenAudioPlayer.src = '';
|
1211 |
}
|
1212 |
-
generateBtn.disabled = false;
|
1213 |
-
generateBtn.innerHTML = '✨ تولید صدا با آلفا';
|
1214 |
}
|
|
|
|
|
|
|
|
|
1215 |
|
|
|
1216 |
async function generateAudio(event) {
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
}
|
1225 |
-
if (text.length > MAX_CHARS) {
|
1226 |
-
showResultState(false, `خطا: طول متن بیش از ${MAX_CHARS.toLocaleString('fa-IR')} نویسه است.`);
|
1227 |
-
return;
|
1228 |
-
}
|
1229 |
-
|
1230 |
-
const promptVal = promptInput.value;
|
1231 |
-
const temperatureVal = parseFloat(tempSlider.value);
|
1232 |
-
const selectedSpeakerVal = selectedSpeakerIdStorage.value;
|
1233 |
-
const sessionHash = Math.random().toString(36).substring(2);
|
1234 |
-
|
1235 |
-
const payload = {
|
1236 |
-
fn_index: FN_INDEX,
|
1237 |
-
data: [false, null, text, promptVal, selectedSpeakerVal, temperatureVal],
|
1238 |
-
event_data: null,
|
1239 |
-
session_hash: sessionHash
|
1240 |
-
};
|
1241 |
-
|
1242 |
-
try {
|
1243 |
-
const joinQueueResponse = await fetch(JOIN_QUEUE_URL, {
|
1244 |
-
method: "POST",
|
1245 |
-
headers: { "Content-Type": "application/json" },
|
1246 |
-
body: JSON.stringify(payload)
|
1247 |
-
});
|
1248 |
-
|
1249 |
-
if (!joinQueueResponse.ok) {
|
1250 |
-
const errorBody = await joinQueueResponse.text();
|
1251 |
-
console.error("Join Queue Error Body:", errorBody);
|
1252 |
-
throw new Error(`خطا در برقراری ارتباط با سرویس آلفا (${joinQueueResponse.status}). لطفا لحظاتی دیگر تلاش کنید.`);
|
1253 |
-
}
|
1254 |
-
|
1255 |
-
let finalFilePath = null;
|
1256 |
-
const startTime = Date.now();
|
1257 |
-
const timeoutDuration = 90000;
|
1258 |
-
|
1259 |
-
while (Date.now() - startTime < timeoutDuration) {
|
1260 |
-
const dataResponse = await fetch(`${GET_DATA_URL_BASE}?session_hash=${sessionHash}`);
|
1261 |
-
if (!dataResponse.ok) {
|
1262 |
-
const errorBody = await dataResponse.text();
|
1263 |
-
console.error("Get Data Error Body:", errorBody);
|
1264 |
-
throw new Error(`خطا در دریافت داده از سرویس (${dataResponse.status})`);
|
1265 |
-
}
|
1266 |
-
|
1267 |
-
const responseText = await dataResponse.text();
|
1268 |
-
const lines = responseText.trim().split('\n');
|
1269 |
-
|
1270 |
-
for (const line of lines) {
|
1271 |
-
if (!line.startsWith('data:')) continue;
|
1272 |
-
try {
|
1273 |
-
const data = JSON.parse(line.substring(5));
|
1274 |
-
if (data.msg === 'process_generating' || data.msg === 'process_starts') {
|
1275 |
-
// console.log("Processing:", data.output?.progress_data?.[0]?.desc || data.msg);
|
1276 |
-
} else if (data.msg === 'process_completed') {
|
1277 |
-
if (data.success && data.output.data && data.output.data[0] && (data.output.data[0].name || data.output.data[0].path)) {
|
1278 |
-
finalFilePath = data.output.data[0].name || data.output.data[0].path;
|
1279 |
-
} else {
|
1280 |
-
console.error("Invalid server response structure or unsuccessful processing:", data);
|
1281 |
-
throw new Error(data.output?.error || 'خطای ناشناخته در پردازش سرور.');
|
1282 |
-
}
|
1283 |
-
break;
|
1284 |
-
} else if (data.msg === 'queue_full') {
|
1285 |
-
throw new Error('صف پردازش پر است. لطفا کمی بعد تلاش کنید.');
|
1286 |
-
}
|
1287 |
-
} catch (e) {
|
1288 |
-
console.warn("Error parsing JSON from stream:", e, "Line:", line);
|
1289 |
-
}
|
1290 |
-
}
|
1291 |
-
if (finalFilePath) break;
|
1292 |
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
1293 |
-
}
|
1294 |
-
|
1295 |
-
if (finalFilePath) {
|
1296 |
-
const audioUrl = `${FILE_URL_BASE}${finalFilePath}`;
|
1297 |
-
hiddenAudioPlayer.src = audioUrl;
|
1298 |
-
showResultState(true);
|
1299 |
-
} else if (Date.now() - startTime >= timeoutDuration) {
|
1300 |
-
throw new Error('پردازش بیش از حد طول کشید و متوقف شد.');
|
1301 |
-
} else {
|
1302 |
-
throw new Error('فایل صوتی از سرور دریافت نشد یا پردازش ناموفق بود.');
|
1303 |
-
}
|
1304 |
-
|
1305 |
-
} catch (error) {
|
1306 |
-
console.error('خطا در فرآیند تولید صدا:', error);
|
1307 |
-
showResultState(false, `${error.message}`);
|
1308 |
-
}
|
1309 |
}
|
1310 |
|
1311 |
-
//
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
loadingAnimationWrapper.style.display = 'none';
|
1316 |
-
audioPlayerContent.style.display = 'none';
|
1317 |
-
outputSection.classList.remove('has-content');
|
1318 |
});
|
1319 |
</script>
|
1320 |
</body>
|
|
|
13 |
--panel-bg: #FFFFFF;
|
14 |
--panel-border: #E8EEF3;
|
15 |
--text-primary: #121826;
|
16 |
+
--text-secondary: #5C677D;
|
17 |
+
--accent-primary: #3B82F6;
|
18 |
--accent-primary-hover: #2563EB;
|
19 |
+
--accent-secondary: #10B981;
|
20 |
--accent-secondary-hover: #059669;
|
21 |
--input-bg: #F8FAFC;
|
22 |
+
--waveform-color-active: #3B82F6;
|
23 |
+
--waveform-color-inactive: #D0D9E6;
|
24 |
+
--waveform-dashed-line-color: #E0E4E9;
|
25 |
|
26 |
--radius-card: 24px;
|
27 |
--radius-input: 14px;
|
|
|
29 |
--shadow-medium: 0 6px 16px -2px rgba(26, 32, 44, 0.08), 0 3px 8px -3px rgba(26,32,44,0.05);
|
30 |
--shadow-strong: 0 10px 25px -5px rgba(26, 32, 44, 0.12), 0 6px 15px -6px rgba(26,32,44,0.08);
|
31 |
--transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
@keyframes spin {
|
35 |
from { transform: rotate(0deg); }
|
36 |
to { transform: rotate(360deg); }
|
|
|
47 |
padding: 2.5rem 0;
|
48 |
min-height: 100vh;
|
49 |
-webkit-font-smoothing: antialiased;
|
|
|
50 |
display: flex;
|
51 |
justify-content: center;
|
52 |
align-items: flex-start;
|
|
|
59 |
margin: 0 auto;
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
.main-content {
|
63 |
padding: 2.5rem;
|
64 |
background-color: var(--panel-bg);
|
65 |
border-radius: var(--radius-card);
|
66 |
box-shadow: var(--shadow-strong);
|
67 |
border: 1px solid var(--panel-border);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
|
|
|
70 |
#output-section {
|
71 |
margin-top: 3rem;
|
72 |
display: flex;
|
|
|
95 |
display: none !important;
|
96 |
}
|
97 |
|
98 |
+
#status-message {
|
99 |
+
font-weight: 500;
|
100 |
+
color: var(--text-secondary);
|
101 |
+
text-align: center;
|
102 |
+
font-size: 1.1em;
|
103 |
+
}
|
104 |
|
|
|
105 |
#loading-animation-wrapper {
|
106 |
display: none;
|
107 |
flex-direction: column;
|
|
|
110 |
gap: 1.8rem;
|
111 |
width: 100%;
|
112 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
/* --- Custom Audio Player Styles --- */
|
115 |
#audio-player-content {
|
|
|
136 |
font-variant-numeric: tabular-nums;
|
137 |
}
|
138 |
|
139 |
+
/* Waveform Display using Canvas */
|
140 |
.audio-waveform {
|
141 |
flex-grow: 1;
|
142 |
height: 60px;
|
143 |
position: relative;
|
144 |
+
cursor: pointer; /* To indicate it's seekable */
|
145 |
}
|
146 |
+
#waveform-canvas {
|
147 |
position: absolute;
|
148 |
top: 0;
|
149 |
left: 0;
|
150 |
width: 100%;
|
151 |
height: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
+
|
154 |
/* Audio Controls */
|
155 |
.audio-controls-group {
|
156 |
display: flex;
|
|
|
175 |
.audio-skip-btn:active, .audio-play-pause-btn-large:active, .audio-volume-btn:active {
|
176 |
transform: scale(0.9);
|
177 |
}
|
178 |
+
.audio-skip-btn svg { width: 28px; height: 28px; fill: currentColor; }
|
179 |
+
.audio-play-pause-btn-large { padding: 0; width: 50px; height: 50px; }
|
180 |
+
.audio-play-pause-btn-large svg { width: 38px; height: 38px; fill: currentColor; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
.audio-utility-controls {
|
183 |
display: flex;
|
|
|
185 |
justify-content: space-between;
|
186 |
width: 100%;
|
187 |
}
|
188 |
+
.audio-volume-btn svg { width: 24px; height: 24px; fill: currentColor; }
|
|
|
|
|
|
|
|
|
189 |
.audio-speed-btn {
|
190 |
font-family: var(--app-font);
|
191 |
font-size: 0.9em;
|
|
|
198 |
color: var(--text-primary);
|
199 |
box-shadow: var(--shadow-subtle);
|
200 |
}
|
201 |
+
.audio-speed-btn:hover { background-color: var(--input-bg); }
|
|
|
|
|
202 |
|
|
|
203 |
#hidden-audio-player { display: none !important; }
|
204 |
|
|
|
205 |
@media (max-width: 600px) {
|
206 |
+
.main-content, #modal-dialog { padding: 1.5rem; }
|
207 |
+
#audio-player-content { padding: 1rem; }
|
208 |
+
.audio-controls-group { gap: 1rem; }
|
209 |
+
.audio-skip-btn svg { width: 24px; height: 24px; }
|
210 |
+
.audio-play-pause-btn-large { width: 44px; height: 44px; }
|
211 |
+
.audio-play-pause-btn-large svg { width: 32px; height: 32px; }
|
212 |
+
}
|
213 |
+
/* Other styles for modals, forms, etc. are omitted for brevity but should be included from the previous version */
|
214 |
+
.app-header,.form-group,.modal-overlay,#generate-btn { /* Placeholder for other styles */ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
</style>
|
216 |
</head>
|
217 |
<body>
|
218 |
<div class="container">
|
219 |
+
<!-- Header, Form, Modals from previous code... -->
|
|
|
|
|
|
|
|
|
220 |
<main class="main-content">
|
221 |
+
<!-- Form content goes here... -->
|
222 |
+
<form id="tts-form">
|
223 |
+
<!-- All form-groups go here -->
|
224 |
+
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
<div id="output-section">
|
227 |
<div id="status-message">صدای تولید شده در اینجا نمایش داده خواهد شد.</div>
|
228 |
+
<div id="loading-animation-wrapper">...</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
|
230 |
<!-- Custom Audio Player Structure -->
|
231 |
<div id="audio-player-content">
|
232 |
<div class="audio-waveform-container">
|
233 |
<span class="audio-time audio-current-time">0:00</span>
|
234 |
<div class="audio-waveform">
|
235 |
+
<canvas id="waveform-canvas"></canvas>
|
|
|
236 |
</div>
|
237 |
<span class="audio-time audio-total-time">0:00</span>
|
238 |
</div>
|
|
|
258 |
<button class="audio-speed-btn">1x</button>
|
259 |
</div>
|
260 |
</div>
|
261 |
+
<audio id="hidden-audio-player" crossorigin="anonymous"></audio>
|
262 |
</div>
|
263 |
</main>
|
264 |
</div>
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
<script>
|
267 |
document.addEventListener('DOMContentLoaded', () => {
|
268 |
+
// All previous variables for elements, modals, etc. go here...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
const hiddenAudioPlayer = document.getElementById('hidden-audio-player');
|
270 |
const audioPlayerContent = document.getElementById('audio-player-content');
|
271 |
+
const waveformCanvas = document.getElementById('waveform-canvas');
|
272 |
+
const canvasCtx = waveformCanvas.getContext('2d');
|
273 |
+
|
274 |
+
// Other element variables...
|
275 |
const audioCurrentTimeSpan = audioPlayerContent.querySelector('.audio-current-time');
|
276 |
const audioTotalTimeSpan = audioPlayerContent.querySelector('.audio-total-time');
|
|
|
277 |
const playPauseBtn = audioPlayerContent.querySelector('.audio-play-pause-btn-large');
|
278 |
const playIcon = playPauseBtn.querySelector('.play-icon');
|
279 |
const pauseIcon = playPauseBtn.querySelector('.pause-icon');
|
|
|
284 |
const volumeMuteIcon = volumeBtn.querySelector('.volume-mute-icon');
|
285 |
const speedBtn = audioPlayerContent.querySelector('.audio-speed-btn');
|
286 |
|
287 |
+
let audioContext;
|
288 |
+
let audioBuffer; // To store the decoded audio data
|
289 |
|
290 |
+
// --- Web Audio API and Waveform Drawing ---
|
|
|
|
|
|
|
|
|
291 |
|
292 |
+
async function generateRealWaveform(audioUrl) {
|
293 |
+
// Initialize AudioContext on user interaction
|
294 |
+
if (!audioContext) {
|
295 |
+
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
|
|
|
|
|
296 |
}
|
|
|
|
|
297 |
|
298 |
+
try {
|
299 |
+
// Fetch the audio file as a blob
|
300 |
+
const response = await fetch(audioUrl, { mode: 'cors' });
|
301 |
+
if (!response.ok) {
|
302 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
303 |
+
}
|
304 |
+
const arrayBuffer = await response.arrayBuffer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
+
// Decode the audio data
|
307 |
+
audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
|
308 |
+
drawWaveform(audioBuffer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
+
} catch (error) {
|
311 |
+
console.error('Error processing audio for waveform:', error);
|
312 |
+
console.error("This is likely a CORS issue. The audio server must send 'Access-Control-Allow-Origin: *' header for waveform analysis to work.");
|
313 |
+
// Fallback: Clear the canvas if it fails
|
314 |
+
canvasCtx.clearRect(0, 0, waveformCanvas.width, waveformCanvas.height);
|
315 |
+
alert("متاسفانه به دلیل محدودیتهای امنیتی (CORS) امکان تولید موج صوتی واقعی وجود ندارد.");
|
316 |
+
}
|
317 |
}
|
318 |
|
319 |
+
function drawWaveform(buffer, progress = 0) {
|
320 |
+
const canvas = waveformCanvas;
|
321 |
+
const ctx = canvasCtx;
|
322 |
+
const dpr = window.devicePixelRatio || 1;
|
323 |
+
|
324 |
+
// Set canvas dimensions based on its display size
|
325 |
+
const rect = canvas.getBoundingClientRect();
|
326 |
+
canvas.width = rect.width * dpr;
|
327 |
+
canvas.height = rect.height * dpr;
|
328 |
+
ctx.scale(dpr, dpr);
|
329 |
+
|
330 |
+
const data = buffer.getChannelData(0); // Use the first channel
|
331 |
+
const barWidth = 3;
|
332 |
+
const barGap = 2;
|
333 |
+
const totalBarWidth = barWidth + barGap;
|
334 |
+
const numBars = Math.floor(canvas.width / dpr / totalBarWidth);
|
335 |
+
const step = Math.floor(data.length / numBars);
|
336 |
+
|
337 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
338 |
+
|
339 |
+
// Draw the inactive (grey) waveform
|
340 |
+
for (let i = 0; i < numBars; i++) {
|
341 |
+
let min = 1.0;
|
342 |
+
let max = -1.0;
|
343 |
|
344 |
+
for (let j = 0; j < step; j++) {
|
345 |
+
const datum = data[(i * step) + j];
|
346 |
+
if (datum < min) min = datum;
|
347 |
+
if (datum > max) max = datum;
|
348 |
+
}
|
|
|
|
|
|
|
|
|
349 |
|
350 |
+
const amp = (max - min); // Amplitude for this segment
|
351 |
+
const barHeight = Math.max(1, amp * (canvas.height / dpr / 2));
|
352 |
+
const y = (canvas.height / dpr / 2) - (barHeight / 2);
|
353 |
+
const x = i * totalBarWidth;
|
354 |
+
|
355 |
+
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--waveform-color-inactive').trim();
|
356 |
+
ctx.fillRect(x, y, barWidth, barHeight);
|
357 |
}
|
358 |
+
|
359 |
+
// Draw the active (blue) progress overlay
|
360 |
+
if (progress > 0) {
|
361 |
+
ctx.save();
|
362 |
+
ctx.globalCompositeOperation = 'source-atop'; // This will only draw on top of existing pixels
|
363 |
+
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--waveform-color-active').trim();
|
364 |
+
ctx.fillRect(0, 0, progress * (canvas.width / dpr), canvas.height);
|
365 |
+
ctx.restore();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
}
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
+
// Draw the dashed line
|
369 |
+
ctx.beginPath();
|
370 |
+
ctx.strokeStyle = getComputedStyle(document.documentElement).getPropertyValue('--waveform-dashed-line-color').trim();
|
371 |
+
ctx.lineWidth = 1;
|
372 |
+
ctx.setLineDash([4, 2]);
|
373 |
+
ctx.moveTo(0, canvas.height / dpr / 2);
|
374 |
+
ctx.lineTo(canvas.width / dpr, canvas.height / dpr / 2);
|
375 |
+
ctx.stroke();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
}
|
377 |
+
|
378 |
+
// --- Player UI and State Management ---
|
379 |
|
380 |
function formatTime(seconds) {
|
381 |
if (isNaN(seconds) || seconds < 0) return '0:00';
|
|
|
384 |
return `${minutes}:${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`;
|
385 |
}
|
386 |
|
|
|
387 |
function updatePlayerUI() {
|
388 |
+
// Update play/pause icon
|
389 |
+
playIcon.style.display = hiddenAudioPlayer.paused ? 'block' : 'none';
|
390 |
+
pauseIcon.style.display = hiddenAudioPlayer.paused ? 'none' : 'block';
|
391 |
+
|
392 |
+
// Update time display
|
|
|
|
|
|
|
393 |
const currentTime = hiddenAudioPlayer.currentTime;
|
394 |
const duration = hiddenAudioPlayer.duration;
|
395 |
audioCurrentTimeSpan.textContent = formatTime(currentTime);
|
396 |
|
397 |
if (isFinite(duration) && duration > 0) {
|
398 |
audioTotalTimeSpan.textContent = formatTime(duration);
|
399 |
+
if (audioBuffer) {
|
400 |
+
// Redraw the waveform with the new progress
|
401 |
+
drawWaveform(audioBuffer, currentTime / duration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
}
|
403 |
} else {
|
404 |
audioTotalTimeSpan.textContent = '0:00';
|
|
|
|
|
|
|
|
|
405 |
}
|
406 |
}
|
407 |
+
|
408 |
+
// Event listener for seeking on the canvas
|
409 |
+
waveformCanvas.addEventListener('click', (e) => {
|
410 |
+
if (!hiddenAudioPlayer.duration) return;
|
411 |
+
const rect = waveformCanvas.getBoundingClientRect();
|
412 |
+
const x = e.clientX - rect.left;
|
413 |
+
const clickPositionRatio = x / rect.width;
|
414 |
+
hiddenAudioPlayer.currentTime = clickPositionRatio * hiddenAudioPlayer.duration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
});
|
416 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
|
418 |
+
function showResultState(isSuccess, message = '', audioUrl = '') {
|
419 |
+
const loadingAnimationWrapper = document.getElementById('loading-animation-wrapper');
|
420 |
+
const statusMessage = document.getElementById('status-message');
|
421 |
+
const outputSection = document.getElementById('output-section');
|
422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
loadingAnimationWrapper.style.display = 'none';
|
424 |
+
if (isSuccess && audioUrl) {
|
425 |
statusMessage.style.display = 'none';
|
426 |
audioPlayerContent.style.display = 'flex';
|
427 |
outputSection.classList.add('has-content');
|
428 |
+
|
429 |
+
// Generate the real waveform
|
430 |
+
generateRealWaveform(audioUrl);
|
431 |
+
|
432 |
hiddenAudioPlayer.play();
|
433 |
} else {
|
434 |
+
// Handle failure...
|
|
|
|
|
|
|
|
|
|
|
435 |
}
|
|
|
|
|
436 |
}
|
437 |
+
|
438 |
+
// Rest of your JS code (event listeners for buttons, API calls, etc.)
|
439 |
+
// Make sure the `generateAudio` function calls `showResultState` like this:
|
440 |
+
// showResultState(true, '', audioUrl);
|
441 |
|
442 |
+
// Placeholder for the main API call function
|
443 |
async function generateAudio(event) {
|
444 |
+
// ... your existing API call logic ...
|
445 |
+
// On success:
|
446 |
+
// const audioUrl = `${FILE_URL_BASE}${finalFilePath}`;
|
447 |
+
// hiddenAudioPlayer.src = audioUrl;
|
448 |
+
// showResultState(true, '', audioUrl);
|
449 |
+
// On failure:
|
450 |
+
// showResultState(false, 'Error message');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
}
|
452 |
|
453 |
+
// All other event listeners for player buttons...
|
454 |
+
playPauseBtn.addEventListener('click', () => { /* ... */ });
|
455 |
+
skipBackwardBtn.addEventListener('click', () => { /* ... */ });
|
456 |
+
// etc.
|
|
|
|
|
|
|
457 |
});
|
458 |
</script>
|
459 |
</body>
|