Opera8 commited on
Commit
f6b0fbc
·
verified ·
1 Parent(s): 76e5094

Create templates/separate-audio.html

Browse files
Files changed (1) hide show
  1. templates/separate-audio.html +1226 -0
templates/separate-audio.html ADDED
@@ -0,0 +1,1226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fa" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>جداساز حرفه‌ای صدا</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
8
+ <style>
9
+ :root {
10
+ --app-font: 'Vazirmatn', sans-serif;
11
+ --app-bg: #F8F9FC;
12
+ --panel-bg: #FFFFFF;
13
+ --panel-border: #EAEFF7;
14
+ --input-bg: #F6F8FB;
15
+ --input-border: #E1E7EF;
16
+ --text-primary: #1A202C;
17
+ --text-secondary: #626F86;
18
+ --text-tertiary: #8A94A6;
19
+ --accent-primary: #4A6CFA;
20
+ --accent-primary-hover: #3553D6;
21
+ --accent-primary-glow: rgba(74, 108, 250, 0.25);
22
+ --accent-secondary: #0FD4A8;
23
+ --success-color: #38A169;
24
+ --danger-color: #e53e3e;
25
+ --danger-color-hover: #c53030;
26
+ --shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03);
27
+ --shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04);
28
+ --shadow-lg: 0 10px 15px -3px rgba(26, 32, 44, 0.06), 0 4px 6px -4px rgba(26, 32, 44, 0.05);
29
+ --shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05);
30
+ --radius-card: 24px;
31
+ --radius-btn: 14px;
32
+ --radius-input: 12px;
33
+ --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
34
+ --igadlm-alpha-color-warning-bg: #FFFBEB;
35
+ --igadlm-alpha-color-warning-border: #FBBF24;
36
+ --igadlm-alpha-color-warning-text: #B45309;
37
+ }
38
+
39
+ @keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
40
+ @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
41
+ @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
42
+
43
+ *, *::before, *::after { box-sizing: border-box; }
44
+
45
+ body {
46
+ font-family: var(--app-font);
47
+ background-color: var(--app-bg);
48
+ color: var(--text-primary);
49
+ line-height: 1.6;
50
+ padding: 2.5rem 1rem;
51
+ margin: 0;
52
+ display: flex;
53
+ justify-content: center;
54
+ align-items: flex-start;
55
+ min-height: 100vh;
56
+ }
57
+ .container { max-width: 820px; width: 100%; }
58
+
59
+ header {
60
+ text-align: center;
61
+ margin-bottom: 2.5rem;
62
+ animation: fadeIn 0.8s 0.1s ease-out backwards;
63
+ position: relative;
64
+ padding: 2rem 0;
65
+ overflow: hidden;
66
+ }
67
+ #neural-network-canvas {
68
+ position: absolute;
69
+ top: 0;
70
+ left: 0;
71
+ width: 100%;
72
+ height: 100%;
73
+ z-index: 1;
74
+ }
75
+ .header-content {
76
+ position: relative;
77
+ z-index: 2;
78
+ }
79
+
80
+ .logo {
81
+ width: 80px;
82
+ height: 80px;
83
+ margin: 0 auto 1.5rem;
84
+ background: linear-gradient(145deg, var(--accent-primary), var(--accent-secondary));
85
+ border-radius: 25px;
86
+ display: flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ box-shadow: var(--shadow-lg);
90
+ animation: float 3s ease-in-out infinite;
91
+ }
92
+
93
+ h1 {
94
+ font-size: 2.8rem; font-weight: 800; margin: 0;
95
+ background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
96
+ -webkit-background-clip: text; -webkit-text-fill-color: transparent;
97
+ letter-spacing: -1px;
98
+ }
99
+ .subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0.5rem; }
100
+
101
+ main {
102
+ padding: 2.5rem;
103
+ background-color: var(--panel-bg);
104
+ border-radius: var(--radius-card);
105
+ box-shadow: var(--shadow-xl);
106
+ border: 1px solid var(--panel-border);
107
+ animation: fadeIn 0.8s 0.3s ease-out backwards;
108
+ }
109
+
110
+ .form-group { margin-bottom: 2.5rem; }
111
+ .form-label {
112
+ display: flex; align-items: center; gap: 0.75rem;
113
+ font-weight: 700; color: var(--text-primary); font-size: 1.2em;
114
+ margin-bottom: 1.2rem;
115
+ }
116
+ .form-label svg { width: 24px; height: 24px; color: var(--accent-primary); }
117
+ label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-secondary); }
118
+
119
+ .audio-input-container {
120
+ position: relative;
121
+ border: 2px dashed var(--input-border);
122
+ border-radius: var(--radius-input);
123
+ padding: 1.5rem;
124
+ text-align: center;
125
+ cursor: pointer;
126
+ transition: var(--transition-smooth);
127
+ background-color: var(--input-bg);
128
+ min-height: 80px;
129
+ display: flex;
130
+ justify-content: center;
131
+ align-items: center;
132
+ }
133
+ .audio-input-container:hover, .audio-input-container.drag-over {
134
+ border-color: var(--accent-primary);
135
+ background-color: #fff;
136
+ box-shadow: 0 0 15px var(--accent-primary-glow);
137
+ }
138
+ .audio-input-container.has-file {
139
+ border-style: solid;
140
+ border-color: var(--success-color);
141
+ background-color: #fff;
142
+ box-shadow: 0 0 15px rgba(56, 161, 105, 0.2);
143
+ cursor: default;
144
+ }
145
+ #audio-prompt { color: var(--text-secondary); font-weight: 500; }
146
+ .audio-player { display: none; align-items: center; width: 100%; gap: 1.5rem; }
147
+ .audio-input-container.has-file .audio-player { display: flex; }
148
+ .audio-input-container.has-file #audio-prompt { display: none; }
149
+ .play-pause-btn {
150
+ background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
151
+ border: none; border-radius: 50%; width: 52px; height: 52px;
152
+ display: flex; align-items: center; justify-content: center;
153
+ cursor: pointer; transition: var(--transition-smooth); flex-shrink: 0; box-shadow: var(--shadow-md);
154
+ }
155
+ .play-pause-btn:hover { transform: scale(1.08); box-shadow: var(--shadow-lg); }
156
+ .play-pause-btn svg { width: 26px; height: 26px; color: white; }
157
+ .play-pause-btn .icon-pause { display: none; }
158
+ .waveform-container { flex-grow: 1; display: flex; flex-direction: column; gap: 0.5rem; }
159
+ #waveform { width: 100%; height: 60px; cursor: pointer; background-color: var(--app-bg); border-radius: 8px; border: 1px solid var(--input-border); }
160
+ .audio-info { font-size: 0.85rem; color: var(--text-tertiary); width: 100%; display: flex; justify-content: space-between; padding: 0 0.25rem; }
161
+ #audioFileName { font-weight: 500; color: var(--text-secondary); word-break: break-all; text-align: right; }
162
+ #resetAudioBtn {
163
+ position: absolute; top: -12px; left: -12px; z-index: 10;
164
+ background-color: var(--panel-bg); border: 1px solid var(--panel-border); color: var(--text-tertiary);
165
+ width: 28px; height: 28px; border-radius: 50%; font-size: 24px; font-weight: bold; line-height: 0;
166
+ cursor: flex; align-items: center; justify-content: center; padding: 0 0 4px 1px;
167
+ box-shadow: var(--shadow-md); transition: var(--transition-smooth);
168
+ opacity: 0; transform: scale(0.8); pointer-events: none;
169
+ }
170
+ .audio-input-container.has-file #resetAudioBtn { opacity: 1; transform: scale(1); pointer-events: all; }
171
+ #resetAudioBtn:hover {
172
+ background-color: var(--danger-color); color: white;
173
+ border-color: var(--danger-color-hover); transform: scale(1.1) rotate(90deg);
174
+ }
175
+
176
+ .settings-grid-redesigned { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
177
+ .checkbox-card {
178
+ position: relative; cursor: pointer; background-color: var(--input-bg);
179
+ border: 2px solid var(--input-border); border-radius: var(--radius-btn); padding: 1rem;
180
+ transition: var(--transition-smooth); text-align: center;
181
+ }
182
+ .checkbox-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent-primary-hover); }
183
+ .checkbox-card input[type="radio"], .checkbox-card input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
184
+ .card-content { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; pointer-events: none; }
185
+ .card-icon svg { width: 36px; height: 36px; color: var(--text-tertiary); transition: var(--transition-smooth); }
186
+ .card-label { font-weight: 600; font-size: 0.95rem; color: var(--text-secondary); transition: var(--transition-smooth); }
187
+ .checkbox-card:has(input:checked) {
188
+ background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); border-color: transparent; color: white;
189
+ box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px rgba(15, 212, 168, 0.3); transform: translateY(-4px) scale(1.02);
190
+ }
191
+ .checkbox-card:has(input:checked) .card-icon svg, .checkbox-card:has(input:checked) .card-label { color: white; }
192
+ .select-card {
193
+ grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem;
194
+ background-color: var(--input-bg); border: 2px solid var(--input-border); border-radius: var(--radius-btn); padding: 0.5rem 1rem;
195
+ }
196
+ .select-card .card-icon svg { width: 28px; height: 28px; color: var(--text-tertiary); }
197
+ .select-card select {
198
+ width: 100%; padding: 0.75rem 0.5rem; border: none; background-color: transparent;
199
+ font-family: inherit; font-weight: 600; font-size: 1rem; color: var(--text-primary);
200
+ appearance: none; -webkit-appearance: none; cursor: pointer;
201
+ }
202
+ .select-card select:focus { outline: none; }
203
+ .settings-subheader {
204
+ font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 1rem;
205
+ grid-column: 1 / -1; padding-bottom: 0.5rem; border-bottom: 1px solid var(--panel-border);
206
+ }
207
+
208
+ details { border: 1px solid var(--panel-border); border-radius: var(--radius-card); margin-bottom: 1.5rem; background-color: var(--app-bg); transition: var(--transition-smooth); }
209
+ details[open] { box-shadow: var(--shadow-md); }
210
+ summary {
211
+ font-weight: 600; color: var(--text-primary); font-size: 1.125rem; padding: 1.25rem 1.5rem;
212
+ cursor: pointer; outline: none; list-style: none; display: flex; justify-content: space-between; align-items: center;
213
+ }
214
+ summary::-webkit-details-marker { display: none; }
215
+ summary::after { content: '▼'; font-size: 0.8em; color: var(--text-tertiary); transition: transform 0.2s ease-in-out; }
216
+ details[open] summary::after { transform: rotate(180deg); }
217
+ .details-content { padding: 0 1.5rem 1.5rem; }
218
+
219
+ button#generateBtn {
220
+ display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 1.1rem;
221
+ font-size: 1.2rem; font-weight: 700; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
222
+ color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease;
223
+ box-shadow: 0 6px 12px -3px var(--accent-primary-glow), 0 6px 12px -3px rgba(15, 212, 168, 0.25); margin-top: 1.5rem;
224
+ }
225
+ button#generateBtn:hover:not(:disabled) {
226
+ transform: translateY(-5px) scale(1.02); box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px rgba(15, 212, 168, 0.3);
227
+ }
228
+ button#generateBtn:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; opacity: 0.7; }
229
+
230
+ #result-container { border: 1px solid var(--panel-border); border-radius: var(--radius-card); padding: 1.5rem; background-color: var(--app-bg); box-shadow: var(--shadow-sm) inset; }
231
+ #progress-container { margin-top: 2rem; }
232
+ .progress-steps {
233
+ list-style: none; padding: 0; margin: 0 0 1rem 0; display: flex;
234
+ justify-content: space-between; position: relative;
235
+ }
236
+ .progress-steps::before {
237
+ content: ''; position: absolute; top: 20px; right: 0; transform: translateY(-50%);
238
+ height: 4px; width: 100%; background-color: var(--input-border); z-index: 1;
239
+ }
240
+ .progress-steps::after {
241
+ content: ''; position: absolute; top: 20px; right: 0; transform: translateY(-50%);
242
+ height: 4px; width: 0; background-color: var(--accent-primary); z-index: 2; transition: width 0.4s ease;
243
+ }
244
+ .progress-steps.step-2::after { width: 50%; } .progress-steps.step-3::after { width: 100%; }
245
+ .progress-steps.completed::after { background-color: var(--success-color); }
246
+ .progress-steps.error::after { background-color: var(--danger-color); }
247
+
248
+ .step { text-align: center; position: relative; z-index: 3; flex: 1; }
249
+ .step-icon {
250
+ width: 40px; height: 40px; border-radius: 50%; background-color: var(--panel-bg);
251
+ border: 4px solid var(--input-border); display: inline-flex; align-items: center; justify-content: center; transition: border-color 0.4s ease;
252
+ }
253
+ .step-icon svg { width: 20px; height: 20px; color: var(--text-tertiary); }
254
+ .step-label { font-size: 0.875rem; color: var(--text-tertiary); margin-top: 0.5rem; font-weight: 500;}
255
+ .step.active .step-icon { border-color: var(--accent-primary); }
256
+ .step.active .step-icon svg { color: var(--accent-primary); animation: spin 1.5s linear infinite; }
257
+ .step.active .step-label { color: var(--accent-primary); font-weight: 600; }
258
+ .step.completed .step-icon { border-color: var(--success-color); background-color: var(--success-color); }
259
+ .step.completed .step-icon svg { color: white; animation: none; }
260
+ .step.completed .step-label { color: var(--text-primary); }
261
+ .step.error .step-icon { border-color: var(--danger-color); background-color: var(--danger-color); }
262
+ .step.error .step-icon svg { color: white; animation: none; }
263
+ .step.error .step-label { color: var(--danger-color); }
264
+ #progress-status-text { text-align: center; color: var(--text-secondary); height: 2rem; font-weight: 500; }
265
+
266
+ #result-output {
267
+ display: none; background: #fff; border: 1px solid var(--panel-border);
268
+ border-radius: var(--radius-card); padding: 1.5rem 2rem; box-shadow: var(--shadow-md); animation: fadeIn 0.5s;
269
+ }
270
+ .output-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--panel-border); }
271
+ .output-header svg { width: 28px; height: 28px; color: var(--success-color); }
272
+ .output-header h3 { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
273
+
274
+ .output-player-container {
275
+ background-color: var(--input-bg);
276
+ border: 1px solid var(--panel-border);
277
+ border-radius: var(--radius-btn);
278
+ padding: 0.75rem;
279
+ margin-bottom: 1.5rem;
280
+ }
281
+ .wa-player-card {
282
+ display: flex;
283
+ align-items: center;
284
+ gap: 1rem;
285
+ }
286
+ .wa-play-pause {
287
+ background-color: var(--accent-primary);
288
+ border: none; border-radius: 50%; width: 48px; height: 48px;
289
+ display: flex; align-items: center; justify-content: center;
290
+ cursor: pointer; transition: var(--transition-smooth); flex-shrink: 0; box-shadow: var(--shadow-sm);
291
+ }
292
+ .wa-play-pause:hover { transform: scale(1.05); background-color: var(--accent-primary-hover); }
293
+ .wa-play-pause svg { color: white; width: 24px; height: 24px; margin-right: 2px; }
294
+ .wa-play-pause .wa-icon-pause { display: none; margin-right: 0; }
295
+ .wa-play-pause.playing .wa-icon-pause { display: block; }
296
+ .wa-play-pause.playing .wa-icon-play { display: none; }
297
+
298
+ .wa-timeline-container {
299
+ flex-grow: 1;
300
+ position: relative;
301
+ height: 50px;
302
+ display: flex;
303
+ align-items: center;
304
+ cursor: pointer;
305
+ }
306
+ #wa-waveform-canvas {
307
+ width: 100%;
308
+ height: 100%;
309
+ }
310
+ .wa-scrubber-container {
311
+ position: absolute;
312
+ top: 0;
313
+ right: 0;
314
+ width: 15px;
315
+ height: 100%;
316
+ display: flex;
317
+ align-items: center;
318
+ transform: translateX(50%);
319
+ pointer-events: none;
320
+ }
321
+ .wa-scrubber-handle {
322
+ width: 15px;
323
+ height: 15px;
324
+ background-color: var(--accent-primary);
325
+ border-radius: 50%;
326
+ position: relative;
327
+ box-shadow: var(--shadow-md);
328
+ }
329
+ .wa-scrubber-loader {
330
+ position: absolute;
331
+ top: 50%;
332
+ left: 50%;
333
+ width: 30px;
334
+ height: 30px;
335
+ margin-top: -15px;
336
+ margin-left: -15px;
337
+ border: 3px solid rgba(74, 108, 250, 0.2);
338
+ border-top-color: var(--accent-primary);
339
+ border-radius: 50%;
340
+ animation: spin 1s linear infinite;
341
+ opacity: 0;
342
+ transition: opacity 0.2s;
343
+ }
344
+ .wa-scrubber-container.loading .wa-scrubber-loader {
345
+ opacity: 1;
346
+ }
347
+
348
+ .wa-time-display {
349
+ font-size: 0.9rem;
350
+ font-weight: 500;
351
+ color: var(--text-secondary);
352
+ padding-left: 0.5rem;
353
+ min-width: 45px;
354
+ text-align: center;
355
+ font-variant-numeric: tabular-nums;
356
+ }
357
+
358
+ a.download-button {
359
+ display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 0.9rem;
360
+ font-size: 1.1rem; font-weight: 600; background-color: var(--accent-primary); color: #fff; text-decoration: none;
361
+ border: none; border-radius: var(--radius-btn); cursor: pointer; transition: var(--transition-smooth);
362
+ }
363
+ a.download-button:hover { background-color: var(--accent-primary-hover); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
364
+ a.download-button svg { width: 22px; height: 22px; }
365
+
366
+ #criticalErrorSection.active { display: block; animation: fadeIn 0.5s; }
367
+
368
+ @keyframes slideInUp {
369
+ from { opacity: 0; transform: translateY(30px); }
370
+ to { opacity: 1; transform: translateY(0); }
371
+ }
372
+ :root {
373
+ --guide-bg: rgba(255, 255, 255, 0.98);
374
+ --guide-border: rgba(102, 126, 234, 0.2);
375
+ --guide-text-title: #2d3748;
376
+ --guide-text-body: #4a5568;
377
+ --guide-accent: #667eea;
378
+ --primary-gradient-guide: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
379
+ --success-gradient-guide: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
380
+ --radius-md-guide: 12px;
381
+ --radius-lg-guide: 20px;
382
+ }
383
+ .ip-reset-guide-container {
384
+ text-align: right; background: var(--guide-bg); backdrop-filter: blur(10px);
385
+ padding: 40px; border-radius: var(--radius-lg-guide);
386
+ box-shadow: var(--shadow-xl); border: 1px solid var(--guide-border); animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
387
+ width: 100%; position: relative; overflow: hidden; box-sizing: border-box;
388
+ }
389
+ .ip-reset-guide-container::before {
390
+ content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--primary-gradient-guide);
391
+ }
392
+ .guide-header { display: flex; align-items: center; margin-bottom: 30px; }
393
+ .guide-header-icon { width: 60px; height: 60px; margin-left: 20px; animation: float 3s ease-in-out infinite; }
394
+ .guide-header h2 { font-size: 1.5rem; color: var(--guide-text-title); font-weight: 700; margin: 0; }
395
+ .guide-header p { color: var(--guide-text-body); font-size: 0.8rem; margin-top: 5px; margin-bottom: 0; }
396
+ .guide-content { font-size: 0.95rem; color: var(--guide-text-body); line-height: 1.8; }
397
+ .info-card { background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%); border: 1px solid rgba(102, 126, 234, 0.2); border-radius: var(--radius-md-guide); padding: 20px; margin: 20px 0; position: relative; overflow: hidden; }
398
+ .info-card p { font-size: 0.85rem; line-height: 1.7; margin: 0; }
399
+ .info-card::before { content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: var(--primary-gradient-guide); }
400
+ .info-card-header { display: flex; align-items: center; margin-bottom: 12px; }
401
+ .info-card-icon { width: 24px; height: 24px; margin-left: 12px; }
402
+ .info-card-title { font-weight: 600; color: var(--guide-text-title); font-size: 1rem; }
403
+ .summary-section { margin-top: 25px; padding: 20px; border-radius: var(--radius-md-guide); background: linear-gradient(135deg, #56ab2f15 0%, #a8e06315 100%); border: 1px solid rgba(86, 171, 47, 0.2); position: relative; overflow: hidden; }
404
+ .summary-section::before { content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: var(--success-gradient-guide); }
405
+ .summary-header { display: flex; align-items: center; margin-bottom: 10px; }
406
+ .summary-icon { width: 24px; height: 24px; margin-left: 10px; }
407
+ .summary-title { font-weight: 600; color: #2f5a33; font-size: 1rem; }
408
+ .summary-text { color: #2f5a33; font-size: 0.9rem; line-height: 1.7; }
409
+ .video-button-container { text-align: center; margin: 25px 0 10px 0; }
410
+ .elegant-video-button { display: inline-flex; align-items: center; justify-content: center; padding: 7px 18px; background-color: #f0f2f5; color: var(--guide-accent); border: 1px solid #e2e8f0; text-decoration: none; border-radius: var(--radius-md-guide); font-weight: 600; font-size: 0.8rem; cursor: pointer; font-family: inherit; transition: all 0.3s ease; box-shadow: var(--shadow-sm); }
411
+ .elegant-video-button:hover { background: var(--primary-gradient-guide); color: white; border-color: transparent; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3); }
412
+ .elegant-video-button-icon { width: 16px; height: 16px; margin-left: 8px; fill: currentColor; }
413
+ .guide-actions { display: flex; gap: 15px; margin-top: 30px; padding-top: 25px; border-top: 1px solid #e2e8f0; }
414
+ .action-button { padding: 14px 24px; border: none; border-radius: var(--radius-md-guide); font-size: 0.95rem; font-weight: 600; cursor: pointer; flex: 1; transition: var(--transition-smooth); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
415
+ .action-button-icon { width: 20px; height: 20px; margin-right: 0; margin-left: 8px; }
416
+ .back-button { background: white; color: var(--guide-text-body); border: 2px solid #e2e8f0; flex: 0.4; }
417
+ .back-button:hover { background: #f7fafc; border-color: var(--guide-accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
418
+ .retry-button { background: var(--primary-gradient-guide); color: white; flex: 0.6; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); }
419
+ .retry-button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); }
420
+
421
+ @media (max-width: 768px) {
422
+ main { padding: 1.5rem; }
423
+ h1 { font-size: 2.2rem; }
424
+ .details-content { grid-template-columns: 1fr; }
425
+ .settings-grid-redesigned { grid-template-columns: repeat(2, 1fr); gap: 0.75rem;}
426
+ .card-icon svg { width: 28px; height: 28px; }
427
+ .card-label { font-size: 0.85rem; }
428
+ #result-output { padding: 1.5rem; }
429
+ .wa-player-card { flex-direction: row; gap: 0.5rem; }
430
+ .wa-play-pause { width: 40px; height: 40px; }
431
+ .wa-play-pause svg { width: 20px; height: 20px; }
432
+ }
433
+ </style>
434
+ </head>
435
+ <body>
436
+ <div class="container">
437
+ <header>
438
+ <canvas id="neural-network-canvas"></canvas>
439
+ <div class="header-content">
440
+ <div class="logo">
441
+ <svg width="50" height="50" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
442
+ <path d="M9 3C6.23858 3 4 5.23858 4 8V16C4 18.7614 6.23858 21 9 21H15C17.7614 21 20 18.7614 20 16V8C20 5.23858 17.7614 3 15 3H9Z" fill="white" opacity="0.9"/>
443
+ <path d="M8 10V14M12 8V16M16 11V13" stroke="#4A6CFA" stroke-width="2" stroke-linecap="round"/>
444
+ </svg>
445
+ </div>
446
+ <h1>جداساز حرفه‌ای صدا</h1>
447
+ <p class="subtitle">وکال و موسیقی پس‌زمینه را با قدرت هوش مصنوعی جدا کنید</p>
448
+ </div>
449
+ </header>
450
+
451
+ <main>
452
+ <div class="form-group">
453
+ <div class="form-label">
454
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>
455
+ ۱. فایل صوتی را بارگذاری کنید
456
+ </div>
457
+ <label for="media_file" class="audio-input-container">
458
+ <div id="audio-prompt">
459
+ <span>فایل صوتی را اینجا بکشید یا برای انتخاب کلیک کنید</span>
460
+ </div>
461
+ <div class="audio-player">
462
+ <button type="button" class="play-pause-btn">
463
+ <svg class="icon-play" viewBox="0 0 24 24"><path fill="currentColor" d="M8 5v14l11-7z"></path></svg>
464
+ <svg class="icon-pause" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"></path></svg>
465
+ </button>
466
+ <div class="waveform-container">
467
+ <canvas id="waveform"></canvas>
468
+ <div class="audio-info">
469
+ <span id="audioFileName"></span>
470
+ <span id="audioDuration"></span>
471
+ </div>
472
+ </div>
473
+ </div>
474
+ <button id="resetAudioBtn" type="button" title="حذف فایل صوتی">&times;</button>
475
+ </label>
476
+ <input type="file" id="media_file" accept="audio/*" required style="display: none;">
477
+ </div>
478
+
479
+ <div class="form-group">
480
+ <div class="form-label">
481
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M4 14h16"/><path d="M4 8h16"/><path d="M4 4h9"/></svg>
482
+ ۲. تنظیمات اصلی را انتخاب کنید
483
+ </div>
484
+ <div class="settings-grid-redesigned">
485
+ <h3 class="settings-subheader">جزء مورد نظر (Stem):</h3>
486
+ <label class="checkbox-card">
487
+ <input type="radio" name="stem" value="vocal" checked>
488
+ <div class="card-content">
489
+ <div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="22"></line></svg></div>
490
+ <span class="card-label">وکال</span>
491
+ </div>
492
+ </label>
493
+ <label class="checkbox-card">
494
+ <input type="radio" name="stem" value="background">
495
+ <div class="card-content">
496
+ <div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg></div>
497
+ <span class="card-label">پس‌زمینه</span>
498
+ </div>
499
+ </label>
500
+
501
+ <div class="select-card">
502
+ <div class="card-icon">
503
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
504
+ </div>
505
+ <select id="target_format">
506
+ <option value="WAV" selected>فرمت خروجی: WAV</option>
507
+ <option value="MP3">فرمت خروجی: MP3</option>
508
+ <option value="FLAC">فرمت خروجی: FLAC</option>
509
+ </select>
510
+ </div>
511
+ </div>
512
+ </div>
513
+
514
+ <details>
515
+ <summary>تنظیمات پیشرفته</summary>
516
+ <div class="details-content" style="padding-top: 1.5rem;">
517
+ <div class="settings-grid-redesigned">
518
+ <h3 class="settings-subheader">گزینه‌های دیگر:</h3>
519
+ <label class="checkbox-card">
520
+ <input type="checkbox" id="main">
521
+ <div class="card-content">
522
+ <div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg></div>
523
+ <span class="card-label">Main</span>
524
+ </div>
525
+ </label>
526
+ <label class="checkbox-card">
527
+ <input type="checkbox" id="dereverb">
528
+ <div class="card-content">
529
+ <div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 8c-4.97 0-9 1.79-9 4s4.03 4 9 4 9-1.79 9-4-4.03-4-9-4Z"/><path d="m18.5 13.51.45-1.01.9-2.02"/><path d="m5.05 13.51-.45-1.01-.9-2.02"/></svg></div>
530
+ <span class="card-label">Dereverb</span>
531
+ </div>
532
+ </label>
533
+ <label class="checkbox-card">
534
+ <input type="checkbox" id="vocal_effects">
535
+ <div class="card-content">
536
+ <div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15.5 2.5a2.5 2.5 0 0 1 3 4.5"/><path d="m14 6 1 1"/><path d="M18.5 6.5a2.5 2.5 0 0 0-3-4.5"/><path d="m18 2-1-1"/><path d="m12 12 2-2"/><path d="m12 12-2 2"/><path d="m6 18-2 2"/><path d="M12 12 6 6"/><path d="M18 12h-2"/><path d="M6 12H4"/><path d="m12 18 v-2"/></svg></div>
537
+ <span class="card-label">افکت وکال</span>
538
+ </div>
539
+ </label>
540
+ <label class="checkbox-card">
541
+ <input type="checkbox" id="background_effects">
542
+ <div class="card-content">
543
+ <div class="card-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-6.219-8.56"/><path d="M10.23 7.23 8 5l-2.23 2.23"/><path d="m13.77 16.77 2.23 2.23 2.23-2.23"/></svg></div>
544
+ <span class="card-label">افکت پس‌زمینه</span>
545
+ </div>
546
+ </label>
547
+ </div>
548
+ <details>
549
+ <summary>پارامترهای پیشرفته وکال</summary>
550
+ <div class="details-content" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem;">
551
+ <div class="form-group"><label>اندازه اتاق ریورب: <span id="vocal_reverb_room_size_val">0.15</span></label><input type="range" id="vocal_reverb_room_size" min="0" max="1" step="0.01" value="0.15" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
552
+ <div class="form-group"><label>میزان Damping ریورب: <span id="vocal_reverb_damping_val">0.7</span></label><input type="range" id="vocal_reverb_damping" min="0" max="1" step="0.01" value="0.7" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
553
+ <div class="form-group"><label>میزان خشکی ریورب: <span id="vocal_reverb_dryness_val">0.8</span></label><input type="range" id="vocal_reverb_dryness" min="0" max="1" step="0.01" value="0.8" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
554
+ <div class="form-group"><label>میزان تری ریورب: <span id="vocal_reverb_wet_level_val">0.2</span></label><input type="range" id="vocal_reverb_wet_level" min="0" max="1" step="0.01" value="0.2" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
555
+ <div class="form-group"><label for="vocal_delay_seconds">تاخیر (ثانیه):</label><input type="number" id="vocal_delay_seconds" step="0.1" value="0"></div>
556
+ <div class="form-group"><label>میزان ترکیب دیلی: <span id="vocal_delay_mix_val">0</span></label><input type="range" id="vocal_delay_mix" min="0" max="1" step="0.01" value="0" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
557
+ <div class="form-group"><label for="vocal_compressor_threshold_db">آستانه کمپرسور (dB):</label><input type="number" id="vocal_compressor_threshold_db" step="1" value="-15"></div>
558
+ <div class="form-group"><label for="vocal_compressor_ratio">نسبت کمپرسور:</label><input type="number" id="vocal_compressor_ratio" step="1" value="4"></div>
559
+ <div class="form-group"><label for="vocal_compressor_attack_ms">زمان Attack (ms):</label><input type="number" id="vocal_compressor_attack_ms" step="1" value="1"></div>
560
+ <div class="form-group"><label for="vocal_compressor_release_ms">زمان Release (ms):</label><input type="number" id="vocal_compressor_release_ms" step="1" value="100"></div>
561
+ <div class="form-group"><label for="vocal_gain_db">گین وکال (dB):</label><input type="number" id="vocal_gain_db" step="1" value="0"></div>
562
+ </div>
563
+ </details>
564
+
565
+ <details>
566
+ <summary>پارامترهای پیشرفته پس‌زمینه</summary>
567
+ <div class="details-content" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem;">
568
+ <div class="form-group"><label for="background_highpass_freq">فرکانس Highpass (Hz):</label><input type="number" id="background_highpass_freq" step="10" value="120"></div>
569
+ <div class="form-group"><label for="background_lowpass_freq">فرکانس Lowpass (Hz):</label><input type="number" id="background_lowpass_freq" step="100" value="11000"></div>
570
+ <div class="form-group"><label>اندازه اتاق ریورب: <span id="background_reverb_room_size_val">0.1</span></label><input type="range" id="background_reverb_room_size" min="0" max="1" step="0.01" value="0.1" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
571
+ <div class="form-group"><label>میزان Damping ریورب: <span id="background_reverb_damping_val">0.5</span></label><input type="range" id="background_reverb_damping" min="0" max="1" step="0.01" value="0.5" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
572
+ <div class="form-group"><label>میزان تری ریورب: <span id="background_reverb_wet_level_val">0.25</span></label><input type="range" id="background_reverb_wet_level" min="0" max="1" step="0.01" value="0.25" oninput="this.previousElementSibling.querySelector('span').textContent = this.value"></div>
573
+ <div class="form-group"><label for="background_compressor_threshold_db">آستانه کمپرسور (dB):</label><input type="number" id="background_compressor_threshold_db" step="1" value="-15"></div>
574
+ <div class="form-group"><label for="background_compressor_ratio">نسبت کمپرسور:</label><input type="number" id="background_compressor_ratio" step="1" value="4"></div>
575
+ <div class="form-group"><label for="background_compressor_attack_ms">زمان Attack (ms):</label><input type="number" id="background_compressor_attack_ms" step="1" value="15"></div>
576
+ <div class="form-group"><label for="background_compressor_release_ms">زمان Release (ms):</label><input type="number" id="background_compressor_release_ms" step="1" value="60"></div>
577
+ <div class="form-group"><label for="background_gain_db">گین پس‌زمینه (dB):</label><input type="number" id="background_gain_db" step="1" value="0"></div>
578
+ </div>
579
+ </details>
580
+ </div>
581
+ </details>
582
+
583
+ <button id="generateBtn">
584
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="24" height="24"><path d="M12.0006 18.26L4.92956 21.0707L6.52246 13.468L0.587891 8.43853L8.61466 7.84003L12.0006 0.5L15.3865 7.84003L23.4133 8.43853L17.4787 13.468L19.0716 21.0707L12.0006 18.26Z"></path></svg>
585
+ <span>شروع پردازش</span>
586
+ </button>
587
+
588
+ <div class="form-group" style="margin-top: 2.5rem;">
589
+ <div class="form-label">
590
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3L12 8L17 10L12 12L10 17L8 12L3 10L8 8L10 3z"/><path d="M21 14l-1.5 3-3-1.5 3-3 1.5 3z"/><path d="M19.5 2.5l-3 1.5 1.5 3 3-1.5-1.5-3z"/></svg>
591
+ ۳. نتیجه
592
+ </div>
593
+ <div id="result-container">
594
+ <div id="progress-container" style="display: none;">
595
+ <ul class="progress-steps" id="progress-steps">
596
+ <li class="step" id="step-1"><div class="step-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13 10V4H6V20H18V10H13ZM11 12H16L12 16V12H11Z"></path></svg></div><div class="step-label">آپلود</div></li>
597
+ <li class="step" id="step-2"><div class="step-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M15.5 13H18V15H15.5V13ZM15.5 9H18V11H15.5V9ZM15.5 5H18V7H15.5V5ZM13.5 19H20C20.5523 19 21 18.5523 21 18V4C21 3.44772 20.5523 3 20 3H4C3.44772 3 3 3.44772 3 4V20C3 20.5523 3.44772 21 4 21H11.5V19H5V5H13.5V19Z"></path></svg></div><div class="step-label">ارسال</div></li>
598
+ <li class="step" id="step-3"><div class="step-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M14.9998 1.414L21.5855 8.00003V20.0001C21.5855 21.1047 20.6902 22.0001 19.5855 22.0001H4.41401C3.30944 22.0001 2.41401 21.1047 2.41401 20.0001V4.00005C2.41401 2.89548 3.30944 2.00005 4.41401 2.00005H14.9998V1.414ZM12.9999 15.0001H15.4141L10.4141 20.0001H7.99988L12.9999 15.0001ZM13.9999 3.41401V8.00003H19.5855L13.9999 3.41401Z"></path></svg></div><div class="step-label">پردازش</div></li>
599
+ </ul>
600
+ <p id="progress-status-text"></p>
601
+ </div>
602
+ <div id="result-output"></div>
603
+ <div id="criticalErrorSection" style="display: none;"></div>
604
+ </div>
605
+ </div>
606
+ </main>
607
+ </div>
608
+
609
+ <script>
610
+ const generateBtn = document.getElementById('generateBtn');
611
+ const mediaFileInput = document.getElementById('media_file');
612
+ const progressContainer = document.getElementById('progress-container');
613
+ const progressSteps = document.getElementById('progress-steps');
614
+ const progressStatusText = document.getElementById('progress-status-text');
615
+ const resultOutput = document.getElementById('result-output');
616
+ const criticalErrorSection = document.getElementById('criticalErrorSection');
617
+
618
+ const step1 = document.getElementById('step-1');
619
+ const step2 = document.getElementById('step-2');
620
+ const step3 = document.getElementById('step-3');
621
+ const checkmarkSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M10.0007 15.1709L19.1931 5.97852L20.6073 7.39273L10.0007 17.9993L3.63672 11.6354L5.05093 10.2212L10.0007 15.1709Z"></path></svg>`;
622
+ const errorSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12.0007 10.5865L16.9504 5.63672L18.3646 7.05093L13.4149 12.0007L18.3646 16.9504L16.9504 18.3646L12.0007 13.4149L7.05093 18.3646L5.63672 16.9504L10.5865 12.0007L5.63672 7.05093L7.05093 5.63672L12.0007 10.5865Z"></path></svg>`;
623
+
624
+ const audioInputContainer = document.querySelector('.audio-input-container');
625
+ const resetAudioBtn = document.getElementById('resetAudioBtn');
626
+ const playPauseBtn = document.querySelector('.play-pause-btn');
627
+ const iconPlay = document.querySelector('.icon-play');
628
+ const iconPause = document.querySelector('.icon-pause');
629
+ const waveformCanvas = document.getElementById('waveform');
630
+ const audioFileNameEl = document.getElementById('audioFileName');
631
+ const audioDurationEl = document.getElementById('audioDuration');
632
+ const waveformCtx = waveformCanvas.getContext('2d');
633
+
634
+ let audioContext, audioBuffer, audioSource, analyser, animationFrameId, isPlaying = false;
635
+ let lastAttemptPayload = null;
636
+ let pollTimer = null;
637
+
638
+ function hideCriticalError() {
639
+ criticalErrorSection.style.display = 'none';
640
+ criticalErrorSection.innerHTML = '';
641
+ }
642
+
643
+ async function retryLastAttempt() {
644
+ if (lastAttemptPayload && lastAttemptPayload.mediaFile) {
645
+ await startSeparationProcess(lastAttemptPayload.mediaFile);
646
+ } else {
647
+ alert("اطلاعات کافی برای تلاش مجدد وجود ندارد. لطفا از نو شروع کنید.");
648
+ }
649
+ }
650
+
651
+ function showGpuQuotaError() {
652
+ progressContainer.style.display = 'none';
653
+ resultOutput.style.display = 'none';
654
+ criticalErrorSection.innerHTML = `
655
+ <div class="ip-reset-guide-container">
656
+ <div class="guide-header"><svg class="guide-header-icon" viewbox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <defs><lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color: #667eea; stop-opacity: 1;"></stop><stop offset="100%" style="stop-color: #764ba2; stop-opacity: 1;"></stop></lineargradient></defs> <circle cx="50" cy="50" r="45" fill="url(#grad1)" opacity="0.1"></circle><circle cx="50" cy="50" r="35" fill="none" stroke="url(#grad1)" stroke-width="2" opacity="0.3"></circle><path d="M35 50 L45 60 L65 40" stroke="url(#grad1)" stroke-width="4" fill="none" stroke-linecap="round" stroke-linejoin="round"></path><circle cx="65" cy="35" r="8" fill="#fee140"></circle><path d="M62 35 L68 35 M65 32 L65 38" stroke="white" stroke-width="2" stroke-linecap="round"></path> </svg>
657
+ <div>
658
+ <h2>یک قدم تا ساخت فایل جدید</h2>
659
+ <p>نیازمند تغییر نقطه دستیابی</p>
660
+ </div>
661
+ </div>
662
+ <div class="guide-content">
663
+ <div class="info-card">
664
+ <div class="info-card-header"><svg class="info-card-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" fill="#667eea" opacity="0.2"></path><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" stroke="#667eea" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span class="info-card-title">راه حل سریع</span></div>
665
+ <p>طبق ویدیو آموزشی پایین بین نقطه دستیابی جابجا شوید تلاش مجدد بزنید تا فایل مجدداً تولید بشه.</p>
666
+ </div>
667
+ <div class="summary-section">
668
+ <div class="summary-header"><svg class="summary-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="#56ab2f" opacity="0.2"></circle><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z" stroke="#56ab2f" stroke-width="2"></path><path d="M9 12l2 2 4-4" stroke="#56ab2f" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span class="summary-title">خلاصه راهنما</span></div>
669
+ <div class="summary-text">هربار که این صفحه را مشاهده کردید: از اینترنت سیم‌کارت استفاده کنید، VPN را خاموش کرده و طبق ویدیو آموزشی پایین نقطه دستیابی رو تغییر دهید. «تلاش مجدد» کلیک کنید. با این روش ساده می‌توانید به صورت نامحدود فایل بسازید! ☘️</div>
670
+ </div>
671
+ <div class="video-button-container"><button id="tutorialLinkBtn" class="elegant-video-button"> <svg class="elegant-video-button-icon" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24"><path d="M8 5v14l11-7z"></path></svg> <span>دیدن ویدیو آموزشی استفاده نامحدود</span> </button></div>
672
+ </div>
673
+ <div class="guide-actions">
674
+ <button class="action-button back-button"> <svg class="action-button-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 12H5M12 19l-7-7 7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span>بازگشت</span> </button>
675
+ <button class="action-button retry-button"> <svg class="action-button-icon" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23 4v6h-6M1 20v-6h6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> <span>تلاش مجدد</span> </button>
676
+ </div>
677
+ </div>`;
678
+
679
+ criticalErrorSection.querySelector('.back-button').addEventListener('click', hideCriticalError);
680
+ criticalErrorSection.querySelector('.retry-button').addEventListener('click', retryLastAttempt);
681
+ document.getElementById('tutorialLinkBtn').addEventListener('click', () => {
682
+ const tutorialUrl = '#/nav/online/news/getSingle/1149635/eyJpdiI6IjhHVGhPQWJwb3E0cjRXbnFWTW5BaUE9PSIsInZhbHVlIjoiS1V0dTdvT21wbXAwSXZaK1RCTG1pVXZqdlFJa1hXV1RKa2FLem9zU3pXMjd5MmlVOGc2YWY0NVdNR3h3Smp1aSIsIm1hYyI6IjY1NTA5ZDYzMjAzMTJhMGQyMWQ4NjA4ZDgyNGZjZDVlY2MyNjdiMjA2NWYzOWRjY2M4ZmVjYWRlMWNlMWQ3ODEiLCJ0YWciOiIifQ==/21135210';
683
+ parent.postMessage({ type: 'NAVIGATE_TO_URL', url: tutorialUrl }, '*');
684
+ });
685
+
686
+ criticalErrorSection.style.display = 'block';
687
+ generateBtn.disabled = false;
688
+ generateBtn.querySelector('span').textContent = 'تلاش مجدد';
689
+ }
690
+
691
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
692
+ audioInputContainer.addEventListener(eventName, e => { e.preventDefault(); e.stopPropagation(); }, false);
693
+ });
694
+ ['dragenter', 'dragover'].forEach(eventName => {
695
+ audioInputContainer.addEventListener(eventName, () => audioInputContainer.classList.add('drag-over'), false);
696
+ });
697
+ ['dragleave', 'drop'].forEach(eventName => {
698
+ audioInputContainer.addEventListener(eventName, () => audioInputContainer.classList.remove('drag-over'), false);
699
+ });
700
+ audioInputContainer.addEventListener('drop', e => {
701
+ mediaFileInput.files = e.dataTransfer.files;
702
+ mediaFileInput.dispatchEvent(new Event('change'));
703
+ });
704
+
705
+ function resetAudioSelection() {
706
+ if (audioSource) { audioSource.stop(); }
707
+ cancelAnimationFrame(animationFrameId);
708
+ isPlaying = false; audioBuffer = null;
709
+ iconPlay.style.display = 'block'; iconPause.style.display = 'none';
710
+ audioInputContainer.classList.remove('has-file');
711
+ mediaFileInput.value = '';
712
+ waveformCtx.clearRect(0, 0, waveformCanvas.width, waveformCanvas.height);
713
+ audioInputContainer.setAttribute('for', 'media_file');
714
+ }
715
+
716
+ async function setupAudio(file) {
717
+ if (!audioContext) { audioContext = new (window.AudioContext || window.webkitAudioContext)(); }
718
+ analyser = audioContext.createAnalyser();
719
+ analyser.fftSize = 2048;
720
+ const arrayBuffer = await file.arrayBuffer();
721
+ audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
722
+ audioFileNameEl.textContent = file.name;
723
+ audioDurationEl.textContent = `${formatTime(audioBuffer.duration)}`;
724
+ audioInputContainer.classList.add('has-file');
725
+ audioInputContainer.removeAttribute('for');
726
+ visualizeAudio();
727
+ }
728
+
729
+ function playAudio() {
730
+ if (!audioBuffer) return;
731
+ if (audioSource) { audioSource.stop(); }
732
+ audioSource = audioContext.createBufferSource();
733
+ audioSource.buffer = audioBuffer;
734
+ audioSource.connect(analyser);
735
+ analyser.connect(audioContext.destination);
736
+ audioSource.start(0);
737
+ isPlaying = true;
738
+ iconPlay.style.display = 'none'; iconPause.style.display = 'block';
739
+ audioSource.onended = () => { isPlaying = false; iconPlay.style.display = 'block'; iconPause.style.display = 'none'; }
740
+ }
741
+
742
+ function stopAudio() {
743
+ if (audioSource) { audioSource.stop(); }
744
+ isPlaying = false;
745
+ iconPlay.style.display = 'block'; iconPause.style.display = 'none';
746
+ }
747
+
748
+ function visualizeAudio() {
749
+ if (!analyser) return;
750
+ const bufferLength = analyser.frequencyBinCount;
751
+ const dataArray = new Uint8Array(bufferLength);
752
+ waveformCtx.clearRect(0, 0, waveformCanvas.width, waveformCanvas.height);
753
+
754
+ function draw() {
755
+ animationFrameId = requestAnimationFrame(draw);
756
+ analyser.getByteTimeDomainData(dataArray);
757
+ waveformCtx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--app-bg').trim();
758
+ waveformCtx.fillRect(0, 0, waveformCanvas.width, waveformCanvas.height);
759
+ waveformCtx.lineWidth = 2;
760
+ waveformCtx.strokeStyle = getComputedStyle(document.documentElement).getPropertyValue('--accent-primary').trim();
761
+ waveformCtx.beginPath();
762
+ const sliceWidth = waveformCanvas.width * 1.0 / bufferLength;
763
+ let x = 0;
764
+ for (let i = 0; i < bufferLength; i++) {
765
+ const v = dataArray[i] / 128.0;
766
+ const y = v * waveformCanvas.height / 2;
767
+ if (i === 0) { waveformCtx.moveTo(x, y); } else { waveformCtx.lineTo(x, y); }
768
+ x += sliceWidth;
769
+ }
770
+ waveformCtx.lineTo(waveformCanvas.width, waveformCanvas.height / 2);
771
+ waveformCtx.stroke();
772
+ }
773
+ draw();
774
+ }
775
+
776
+ function formatTime(seconds) {
777
+ if (isNaN(seconds)) return '0:00';
778
+ const minutes = Math.floor(seconds / 60);
779
+ const secs = Math.floor(seconds % 60);
780
+ return `${minutes}:${secs < 10 ? '0' : ''}${secs}`;
781
+ }
782
+
783
+ mediaFileInput.addEventListener('change', () => {
784
+ const file = mediaFileInput.files[0];
785
+ if (file) { setupAudio(file); } else { resetAudioSelection(); }
786
+ });
787
+
788
+ playPauseBtn.addEventListener('click', () => {
789
+ if (isPlaying) { stopAudio(); } else { playAudio(); }
790
+ });
791
+
792
+ resetAudioBtn.addEventListener('click', (e) => {
793
+ e.preventDefault(); e.stopPropagation(); resetAudioSelection();
794
+ });
795
+
796
+ const resetProgress = () => {
797
+ const originalIcons = {
798
+ 'step-1': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M13 10V4H6V20H18V10H13ZM11 12H16L12 16V12H11Z"></path></svg>`,
799
+ 'step-2': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M15.5 13H18V15H15.5V13ZM15.5 9H18V11H15.5V9ZM15.5 5H18V7H15.5V5ZM13.5 19H20C20.5523 19 21 18.5523 21 18V4C21 3.44772 20.5523 3 20 3H4C3.44772 3 3 3.44772 3 4V20C3 20.5523 3.44772 21 4 21H11.5V19H5V5H13.5V19Z"></path></svg>`,
800
+ 'step-3': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M14.9998 1.414L21.5855 8.00003V20.0001C21.5855 21.1047 20.6902 22.0001 19.5855 22.0001H4.41401C3.30944 22.0001 2.41401 21.1047 2.41401 20.0001V4.00005C2.41401 2.89548 3.30944 2.00005 4.41401 2.00005H14.9998V1.414ZM12.9999 15.0001H15.4141L10.4141 20.0001H7.99988L12.9999 15.0001ZM13.9999 3.41401V8.00003H19.5855L13.9999 3.41401Z"></path></svg>`
801
+ };
802
+ [step1, step2, step3].forEach(step => {
803
+ step.className = 'step';
804
+ step.querySelector('.step-icon').innerHTML = originalIcons[step.id];
805
+ });
806
+ progressSteps.className = 'progress-steps';
807
+ progressStatusText.textContent = '';
808
+ };
809
+
810
+ const updateProgress = (step, message, isError = false) => {
811
+ progressContainer.style.display = 'block';
812
+ resultOutput.style.display = 'none';
813
+ hideCriticalError();
814
+ resetProgress();
815
+
816
+ if (isError) {
817
+ progressSteps.classList.add('error');
818
+ const errorStep = document.getElementById(`step-${step}`);
819
+ if(errorStep) {
820
+ errorStep.classList.add('error');
821
+ errorStep.querySelector('.step-icon').innerHTML = errorSVG;
822
+ }
823
+ for(let i=1; i<step; i++) {
824
+ const completedStep = document.getElementById(`step-${i}`);
825
+ completedStep.classList.add('completed');
826
+ completedStep.querySelector('.step-icon').innerHTML = checkmarkSVG;
827
+ }
828
+ progressSteps.classList.add(`step-${step}`);
829
+ } else {
830
+ if (step > 0) {
831
+ const currentStep = document.getElementById(`step-${step}`);
832
+ if(currentStep) currentStep.classList.add('active');
833
+ progressSteps.classList.add(`step-${step}`);
834
+ }
835
+ if (step === 'completed') {
836
+ [step1, step2, step3].forEach(s => {
837
+ s.classList.add('completed');
838
+ s.querySelector('.step-icon').innerHTML = checkmarkSVG;
839
+ });
840
+ progressSteps.classList.add('completed');
841
+ } else {
842
+ for(let i=1; i<step; i++) {
843
+ const completedStep = document.getElementById(`step-${i}`);
844
+ completedStep.classList.add('completed');
845
+ completedStep.querySelector('.step-icon').innerHTML = checkmarkSVG;
846
+ }
847
+ }
848
+ }
849
+
850
+ progressStatusText.textContent = message;
851
+ };
852
+
853
+ async function startSeparationProcess(mediaFile) {
854
+ generateBtn.disabled = true;
855
+ generateBtn.querySelector('span').textContent = 'در حال پردازش...';
856
+ resultOutput.style.display = 'none';
857
+ resultOutput.innerHTML = '';
858
+ hideCriticalError();
859
+ resetProgress();
860
+
861
+ lastAttemptPayload = { mediaFile };
862
+
863
+ const runId = 'sep_' + Math.random().toString(36).substring(2, 13) + Math.random().toString(36).substring(2, 13);
864
+ const fileExt = mediaFile.name.split('.').pop() || 'mp3';
865
+
866
+ try {
867
+ updateProgress(1, '۱/۳: در حال آپلود فایل صوتی...');
868
+ const formData = new FormData();
869
+ formData.append('file', mediaFile);
870
+ formData.append('run_id', `${runId}_input`);
871
+ formData.append('ext', fileExt);
872
+
873
+ const uploadResponse = await fetch('/api/webhook/upload', { method: 'POST', body: formData });
874
+ if (!uploadResponse.ok) throw new Error('خطا در آپلود فایل.');
875
+
876
+ updateProgress(2, '۲/۳: ارسال درخواست به صف پردازش...');
877
+
878
+ const stem = document.querySelector('input[name="stem"]:checked').value;
879
+ const main = document.getElementById('main').checked ? 'true' : 'false';
880
+ const dereverb = document.getElementById('dereverb').checked ? 'true' : 'false';
881
+ const vocal_effects = document.getElementById('vocal_effects').checked ? 'true' : 'false';
882
+ const background_effects = document.getElementById('background_effects').checked ? 'true' : 'false';
883
+ const vocal_reverb_room_size = document.getElementById('vocal_reverb_room_size').value;
884
+ const vocal_reverb_damping = document.getElementById('vocal_reverb_damping').value;
885
+ const vocal_reverb_dryness = document.getElementById('vocal_reverb_dryness').value;
886
+ const vocal_reverb_wet_level = document.getElementById('vocal_reverb_wet_level').value;
887
+ const vocal_delay_seconds = document.getElementById('vocal_delay_seconds').value;
888
+ const vocal_delay_mix = document.getElementById('vocal_delay_mix').value;
889
+ const vocal_compressor_threshold_db = document.getElementById('vocal_compressor_threshold_db').value;
890
+ const vocal_compressor_ratio = document.getElementById('vocal_compressor_ratio').value;
891
+ const vocal_compressor_attack_ms = document.getElementById('vocal_compressor_attack_ms').value;
892
+ const vocal_compressor_release_ms = document.getElementById('vocal_compressor_release_ms').value;
893
+ const vocal_gain_db = document.getElementById('vocal_gain_db').value;
894
+ const background_highpass_freq = document.getElementById('background_highpass_freq').value;
895
+ const background_lowpass_freq = document.getElementById('background_lowpass_freq').value;
896
+ const background_reverb_room_size = document.getElementById('background_reverb_room_size').value;
897
+ const background_reverb_damping = document.getElementById('background_reverb_damping').value;
898
+ const background_reverb_wet_level = document.getElementById('background_reverb_wet_level').value;
899
+ const background_compressor_threshold_db = document.getElementById('background_compressor_threshold_db').value;
900
+ const background_compressor_ratio = document.getElementById('background_compressor_ratio').value;
901
+ const background_compressor_attack_ms = document.getElementById('background_compressor_attack_ms').value;
902
+ const background_compressor_release_ms = document.getElementById('background_compressor_release_ms').value;
903
+ const background_gain_db = document.getElementById('background_gain_db').value;
904
+ const target_format = document.getElementById('target_format').value;
905
+
906
+ const packedConfig = `VOICECONFIG_SEPARATE_userRunId_${runId}_ext_${fileExt}_stem_${stem}_main_${main}_dereverb_${dereverb}_vocEff_${vocal_effects}_bgEff_${background_effects}_vRevRoom_${vocal_reverb_room_size}_vRevDamp_${vocal_reverb_damping}_vRevDry_${vocal_reverb_dryness}_vRevWet_${vocal_reverb_wet_level}_vDelaySec_${vocal_delay_seconds}_vDelayMix_${vocal_delay_mix}_vCompThresh_${vocal_compressor_threshold_db}_vCompRatio_${vocal_compressor_ratio}_vCompAttack_${vocal_compressor_attack_ms}_vCompRelease_${vocal_compressor_release_ms}_vGain_${vocal_gain_db}_bgHigh_${background_highpass_freq}_bgLow_${background_lowpass_freq}_bgRevRoom_${background_reverb_room_size}_bgRevDamp_${background_reverb_damping}_bgRevWet_${background_reverb_wet_level}_bgCompThresh_${background_compressor_threshold_db}_bgCompRatio_${background_compressor_ratio}_bgCompAttack_${background_compressor_attack_ms}_bgCompRelease_${background_compressor_release_ms}_bgGain_${background_gain_db}_format_${target_format}`;
907
+
908
+ const dispatchResponse = await fetch('/api/generate', {
909
+ method: 'POST',
910
+ headers: { 'Content-Type': 'application/json' },
911
+ body: JSON.stringify({
912
+ prompt: packedConfig,
913
+ width: 1024,
914
+ height: 1024,
915
+ action_name: 'separate-audio'
916
+ })
917
+ });
918
+
919
+ if (!dispatchResponse.ok) throw new Error('خطا در ارسال درخواست به صف.');
920
+ const dispatchResult = await dispatchResponse.json();
921
+ if (dispatchResult.status !== 'success') throw new Error(dispatchResult.message || 'خطا در ارسال درخواست.');
922
+
923
+ updateProgress(3, '۳/۳: منتظر دریافت پاسخ از سرور...');
924
+
925
+ let attempts = 0;
926
+ const maxAttempts = 150;
927
+
928
+ pollTimer = setInterval(async () => {
929
+ try {
930
+ attempts++;
931
+ if (attempts > maxAttempts) {
932
+ clearInterval(pollTimer);
933
+ updateProgress(3, 'خطای زمان انتظار: سرور در زمان مقرر پاسخ نداد.', true);
934
+ generateBtn.disabled = false;
935
+ generateBtn.querySelector('span').textContent = 'شروع پردازش';
936
+ return;
937
+ }
938
+
939
+ const statusResponse = await fetch(`/api/status/${runId}`);
940
+ if (!statusResponse.ok) return;
941
+
942
+ const statusResult = await statusResponse.json();
943
+
944
+ if (statusResult.status === 'ready') {
945
+ clearInterval(pollTimer);
946
+ updateProgress('completed', 'پردازش با موفقیت انجام شد!');
947
+ const audioUrl = statusResult.url;
948
+
949
+ resultOutput.innerHTML = `
950
+ <div class="output-header">
951
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M10.0007 15.1709L19.1931 5.97852L20.6073 7.39273L10.0007 17.9993L3.63672 11.6354L5.05093 10.2212L10.0007 15.1709Z"></path></svg>
952
+ <h3>فایل خروجی شما آماده است</h3>
953
+ </div>
954
+ <div class="output-player-container">
955
+ <div class="wa-player-card">
956
+ <audio id="output-audio-engine" src="${audioUrl}" preload="metadata"></audio>
957
+ <button class="wa-play-pause">
958
+ <svg class="wa-icon-play" viewBox="0 0 24 24"><path fill="currentColor" d="M8 5v14l11-7z"></path></svg>
959
+ <svg class="wa-icon-pause" viewBox="0 0 24 24"><path fill="currentColor" d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"></path></svg>
960
+ </button>
961
+ <div class="wa-timeline-container">
962
+ <canvas id="wa-waveform-canvas"></canvas>
963
+ <div class="wa-scrubber-container">
964
+ <div class="wa-scrubber-handle"></div>
965
+ <div class="wa-scrubber-loader"></div>
966
+ </div>
967
+ </div>
968
+ <div class="wa-time-display">0:00</div>
969
+ </div>
970
+ </div>
971
+ <a href="javascript:void(0);" class="download-button" id="post-message-download-btn" data-url="${audioUrl}">
972
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>
973
+ <span>دانلود فایل</span>
974
+ </a>`;
975
+
976
+ setupOutputPlayer();
977
+
978
+ document.getElementById('post-message-download-btn').addEventListener('click', function(e) {
979
+ e.preventDefault();
980
+ const downloadUrl = this.getAttribute('data-url');
981
+ if (window.parent) {
982
+ window.parent.postMessage({
983
+ type: 'DOWNLOAD_REQUEST',
984
+ url: downloadUrl
985
+ }, '*');
986
+ }
987
+ });
988
+
989
+ resultOutput.style.display = 'block';
990
+ generateBtn.disabled = false;
991
+ generateBtn.querySelector('span').textContent = 'ساخت فایل جدید';
992
+ } else if (statusResult.status === 'failed') {
993
+ clearInterval(pollTimer);
994
+ showGpuQuotaError();
995
+ }
996
+ } catch (pollErr) {
997
+ console.error('Polling error:', pollErr);
998
+ }
999
+ }, 5000);
1000
+
1001
+ } catch (error) {
1002
+ console.error('Error:', error);
1003
+ updateProgress(1, `یک خطا رخ داد: ${error.message}`, true);
1004
+ generateBtn.disabled = false;
1005
+ generateBtn.querySelector('span').textContent = 'شروع پردازش';
1006
+ }
1007
+ }
1008
+
1009
+ function setupOutputPlayer() {
1010
+ const audio = document.getElementById('output-audio-engine');
1011
+ const playBtn = document.querySelector('.wa-play-pause');
1012
+ const timelineContainer = document.querySelector('.wa-timeline-container');
1013
+ const scrubberContainer = document.querySelector('.wa-scrubber-container');
1014
+ const timeDisplay = document.querySelector('.wa-time-display');
1015
+ const canvas = document.getElementById('wa-waveform-canvas');
1016
+ const ctx = canvas.getContext('2d');
1017
+
1018
+ let waveformData = [];
1019
+ let isScrubbing = false;
1020
+ let animationFrameRequest;
1021
+
1022
+ const playedColor = getComputedStyle(document.documentElement).getPropertyValue('--accent-primary').trim();
1023
+ const unplayedColor = getComputedStyle(document.documentElement).getPropertyValue('--text-tertiary').trim();
1024
+
1025
+ function generateWaveformData(numBars) {
1026
+ waveformData = [];
1027
+ for (let i = 0; i < numBars; i++) {
1028
+ const height = Math.random() * 0.7 + 0.25;
1029
+ waveformData.push(height);
1030
+ }
1031
+ }
1032
+
1033
+ function drawWaveform() {
1034
+ const dpr = window.devicePixelRatio || 1;
1035
+ canvas.width = timelineContainer.clientWidth * dpr;
1036
+ canvas.height = timelineContainer.clientHeight * dpr;
1037
+ ctx.scale(dpr, dpr);
1038
+
1039
+ const width = timelineContainer.clientWidth;
1040
+ const height = timelineContainer.clientHeight;
1041
+ const barWidth = 3;
1042
+ const gap = 2;
1043
+ const totalBarWidth = barWidth + gap;
1044
+ const numBars = Math.floor(width / totalBarWidth);
1045
+
1046
+ if (waveformData.length !== numBars) {
1047
+ generateWaveformData(numBars);
1048
+ }
1049
+
1050
+ ctx.clearRect(0, 0, width, height);
1051
+
1052
+ const progress = (audio.currentTime / audio.duration) || 0;
1053
+ const playedWidth = progress * width;
1054
+
1055
+ for (let i = 0; i < numBars; i++) {
1056
+ const barHeight = waveformData[i] * height;
1057
+ const x = i * totalBarWidth;
1058
+ const y = (height - barHeight) / 2;
1059
+
1060
+ const barIsPlayed = x < playedWidth;
1061
+ ctx.fillStyle = barIsPlayed ? playedColor : unplayedColor;
1062
+
1063
+ ctx.beginPath();
1064
+ ctx.roundRect(x, y, barWidth, barHeight, 2);
1065
+ ctx.fill();
1066
+ }
1067
+ }
1068
+
1069
+ function updateUI() {
1070
+ if (!audio.duration) return;
1071
+ const progress = audio.currentTime / audio.duration;
1072
+ const scrubberX = progress * timelineContainer.clientWidth;
1073
+ scrubberContainer.style.left = `${scrubberX}px`;
1074
+
1075
+ timeDisplay.textContent = formatTime(audio.currentTime);
1076
+
1077
+ drawWaveform();
1078
+ animationFrameRequest = requestAnimationFrame(updateUI);
1079
+ }
1080
+
1081
+ playBtn.addEventListener('click', () => audio.paused ? audio.play() : audio.pause());
1082
+
1083
+ audio.addEventListener('play', () => {
1084
+ playBtn.classList.add('playing');
1085
+ cancelAnimationFrame(animationFrameRequest);
1086
+ animationFrameRequest = requestAnimationFrame(updateUI);
1087
+ });
1088
+
1089
+ audio.addEventListener('pause', () => {
1090
+ playBtn.classList.remove('playing');
1091
+ cancelAnimationFrame(animationFrameRequest);
1092
+ });
1093
+
1094
+ audio.addEventListener('ended', () => {
1095
+ playBtn.classList.remove('playing');
1096
+ audio.currentTime = 0;
1097
+ cancelAnimationFrame(animationFrameRequest);
1098
+ requestAnimationFrame(updateUI);
1099
+ });
1100
+
1101
+ audio.addEventListener('loadedmetadata', () => {
1102
+ timeDisplay.textContent = formatTime(0);
1103
+ requestAnimationFrame(updateUI);
1104
+ });
1105
+
1106
+ audio.addEventListener('waiting', () => scrubberContainer.classList.add('loading'));
1107
+ audio.addEventListener('canplay', () => scrubberContainer.classList.remove('loading'));
1108
+ audio.addEventListener('playing', () => scrubberContainer.classList.remove('loading'));
1109
+
1110
+ function handleScrub(e) {
1111
+ if (!audio.duration) return;
1112
+ const rect = timelineContainer.getBoundingClientRect();
1113
+ const clickX = e.clientX || e.touches[0].clientX;
1114
+ const progress = Math.max(0, Math.min(1, (clickX - rect.left) / rect.width));
1115
+ audio.currentTime = progress * audio.duration;
1116
+ requestAnimationFrame(updateUI);
1117
+ }
1118
+
1119
+ const startScrub = (e) => { isScrubbing = true; handleScrub(e); };
1120
+ const endScrub = () => isScrubbing = false;
1121
+ const doScrub = (e) => { if(isScrubbing) handleScrub(e); };
1122
+
1123
+ timelineContainer.addEventListener('mousedown', startScrub);
1124
+ document.addEventListener('mousemove', doScrub);
1125
+ document.addEventListener('mouseup', endScrub);
1126
+
1127
+ timelineContainer.addEventListener('touchstart', startScrub, { passive: true });
1128
+ document.addEventListener('touchmove', doScrub, { passive: true });
1129
+ document.addEventListener('touchend', endScrub);
1130
+
1131
+ window.addEventListener('resize', () => requestAnimationFrame(drawWaveform));
1132
+ }
1133
+
1134
+ generateBtn.addEventListener('click', async () => {
1135
+ const mediaFile = mediaFileInput.files[0];
1136
+ if (!mediaFile) {
1137
+ alert('لطفاً یک فایل صوتی انتخاب کنید.');
1138
+ return;
1139
+ }
1140
+ startSeparationProcess(mediaFile);
1141
+ });
1142
+
1143
+ document.addEventListener('DOMContentLoaded', () => {
1144
+ const canvas = document.getElementById('neural-network-canvas');
1145
+ if (!canvas) return;
1146
+ const header = canvas.parentElement;
1147
+ const ctx = canvas.getContext('2d');
1148
+ let particles = [];
1149
+ const particleCount = 20;
1150
+ const maxDistance = 100;
1151
+ const computedStyles = getComputedStyle(document.documentElement);
1152
+ const particleColor = computedStyles.getPropertyValue('--accent-primary').trim();
1153
+ const lineColor = computedStyles.getPropertyValue('--text-tertiary').trim();
1154
+
1155
+ function resizeCanvas() {
1156
+ canvas.width = header.clientWidth;
1157
+ canvas.height = header.clientHeight;
1158
+ init();
1159
+ }
1160
+
1161
+ class Particle {
1162
+ constructor() {
1163
+ this.x = Math.random() * canvas.width;
1164
+ this.y = Math.random() * canvas.height;
1165
+ this.vx = (Math.random() - 0.5) * 0.3;
1166
+ this.vy = (Math.random() - 0.5) * 0.3;
1167
+ this.radius = 1.2;
1168
+ }
1169
+ update() {
1170
+ this.x += this.vx;
1171
+ this.y += this.vy;
1172
+ if (this.x < 0 || this.x > canvas.width) this.vx *= -1;
1173
+ if (this.y < 0 || this.y > canvas.height) this.vy *= -1;
1174
+ }
1175
+ draw() {
1176
+ ctx.beginPath();
1177
+ ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
1178
+ ctx.fillStyle = particleColor;
1179
+ ctx.fill();
1180
+ }
1181
+ }
1182
+
1183
+ function init() {
1184
+ particles = [];
1185
+ for (let i = 0; i < particleCount; i++) {
1186
+ particles.push(new Particle());
1187
+ }
1188
+ }
1189
+
1190
+ function connectParticles() {
1191
+ for (let i = 0; i < particles.length; i++) {
1192
+ for (let j = i + 1; j < particles.length; j++) {
1193
+ const dx = particles[i].x - particles[j].x;
1194
+ const dy = particles[i].y - particles[j].y;
1195
+ const distance = Math.sqrt(dx * dx + dy * dy);
1196
+ if (distance < maxDistance) {
1197
+ ctx.beginPath();
1198
+ ctx.moveTo(particles[i].x, particles[i].y);
1199
+ ctx.lineTo(particles[j].x, particles[j].y);
1200
+ ctx.strokeStyle = lineColor;
1201
+ ctx.lineWidth = 0.2;
1202
+ ctx.globalAlpha = 1 - distance / maxDistance;
1203
+ ctx.stroke();
1204
+ }
1205
+ }
1206
+ }
1207
+ ctx.globalAlpha = 1;
1208
+ }
1209
+
1210
+ function animate() {
1211
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
1212
+ particles.forEach(particle => {
1213
+ particle.update();
1214
+ particle.draw();
1215
+ });
1216
+ connectParticles();
1217
+ requestAnimationFrame(animate);
1218
+ }
1219
+
1220
+ window.addEventListener('resize', resizeCanvas);
1221
+ resizeCanvas();
1222
+ animate();
1223
+ });
1224
+ </script>
1225
+ </body>
1226
+ </html>