Opera8 commited on
Commit
3d39211
·
verified ·
1 Parent(s): fd5019d

Upload index (15).html

Browse files
Files changed (1) hide show
  1. index (15).html +405 -0
index (15).html ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, maximum-scale=1.0, user-scalable=no">
6
+ <title>استودیو موزیک ACE-Step</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;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
+ --accent-primary: #4A6CFA;
19
+ --accent-glow: rgba(74, 108, 250, 0.2);
20
+ --success-color: #38A169;
21
+ --radius-card: 20px;
22
+ --radius-btn: 14px;
23
+ }
24
+
25
+ * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
26
+
27
+ body {
28
+ font-family: var(--app-font);
29
+ background-color: var(--app-bg);
30
+ color: var(--text-primary);
31
+ margin: 0;
32
+ padding: 20px 15px;
33
+ min-height: 100vh;
34
+ display: flex;
35
+ flex-direction: column;
36
+ align-items: center;
37
+ }
38
+
39
+ .container { max-width: 650px; width: 100%; z-index: 2; position: relative; }
40
+
41
+ /* انیمیشن پس‌زمینه هدر */
42
+ #music-canvas {
43
+ position: fixed; top: 0; left: 0; width: 100%; height: 400px;
44
+ z-index: 0; opacity: 0.5; pointer-events: none;
45
+ mask-image: linear-gradient(to bottom, black, transparent);
46
+ -webkit-mask-image: linear-gradient(to bottom, black, transparent);
47
+ }
48
+
49
+ header { text-align: center; margin-bottom: 2rem; position: relative; }
50
+
51
+ .logo-box {
52
+ width: 80px; height: 80px; margin: 0 auto 15px;
53
+ background: #fff; border-radius: 50%;
54
+ display: flex; align-items: center; justify-content: center;
55
+ box-shadow: 0 10px 25px var(--accent-glow);
56
+ color: var(--accent-primary);
57
+ }
58
+
59
+ h1 {
60
+ font-size: 1.8rem; font-weight: 800; margin: 0;
61
+ background: linear-gradient(90deg, #2d3748, #4A6CFA);
62
+ -webkit-background-clip: text; -webkit-text-fill-color: transparent;
63
+ }
64
+ .subtitle { font-size: 0.9rem; color: var(--text-secondary); margin-top: 5px; }
65
+
66
+ /* کارت‌ها */
67
+ .card {
68
+ background: var(--panel-bg);
69
+ border-radius: var(--radius-card);
70
+ box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
71
+ border: 1px solid var(--panel-border);
72
+ padding: 25px; margin-bottom: 20px;
73
+ transition: transform 0.3s ease;
74
+ }
75
+
76
+ .form-label {
77
+ display: flex; align-items: center; gap: 8px;
78
+ font-weight: 700; margin-bottom: 12px; color: #2d3748;
79
+ }
80
+ .form-label svg { color: var(--accent-primary); width: 20px; }
81
+
82
+ textarea {
83
+ width: 100%; background: var(--input-bg);
84
+ border: 2px solid var(--input-border);
85
+ border-radius: 12px; padding: 15px;
86
+ font-family: inherit; font-size: 1rem; color: #2d3748;
87
+ min-height: 120px; resize: vertical; outline: none;
88
+ transition: border-color 0.3s;
89
+ }
90
+ textarea:focus { border-color: var(--accent-primary); background: #fff; }
91
+
92
+ /* دکمه‌ها */
93
+ .btn-main {
94
+ width: 100%; padding: 16px;
95
+ background: linear-gradient(135deg, var(--accent-primary), #3b5bdb);
96
+ color: #fff; border: none; border-radius: var(--radius-btn);
97
+ font-size: 1.1rem; font-weight: 700; cursor: pointer;
98
+ display: flex; justify-content: center; align-items: center; gap: 10px;
99
+ box-shadow: 0 5px 15px var(--accent-glow);
100
+ transition: transform 0.2s;
101
+ }
102
+ .btn-main:active { transform: scale(0.98); }
103
+ .btn-main:disabled { opacity: 0.7; cursor: not-allowed; filter: grayscale(1); }
104
+
105
+ .btn-outline {
106
+ background: transparent; border: 2px solid var(--input-border);
107
+ color: var(--text-secondary); margin-top: 10px;
108
+ }
109
+ .btn-outline:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
110
+
111
+ /* بخش نتیجه نهایی */
112
+ #finalResult { display: none; animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
113
+
114
+ .player-header {
115
+ display: flex; align-items: center; justify-content: space-between;
116
+ margin-bottom: 15px; padding-bottom: 15px;
117
+ border-bottom: 1px solid var(--panel-border);
118
+ }
119
+
120
+ audio { width: 100%; height: 40px; border-radius: 20px; }
121
+
122
+ .lyrics-container {
123
+ background: var(--input-bg);
124
+ border-radius: 16px;
125
+ padding: 20px;
126
+ max-height: 350px;
127
+ overflow-y: auto;
128
+ white-space: pre-wrap;
129
+ line-height: 2;
130
+ font-size: 1rem;
131
+ color: #4a5568;
132
+ text-align: center;
133
+ border: 1px solid var(--input-border);
134
+ margin-top: 15px;
135
+ }
136
+
137
+ /* استایل تگ‌های شعر */
138
+ .lyrics-tag {
139
+ color: var(--accent-primary);
140
+ font-weight: 800;
141
+ display: block;
142
+ margin-top: 20px;
143
+ margin-bottom: 5px;
144
+ font-size: 0.9em;
145
+ letter-spacing: 1px;
146
+ text-transform: uppercase;
147
+ }
148
+
149
+ /* لودر */
150
+ #loader { display: none; text-align: center; padding: 20px; }
151
+ .wave-bars { display: flex; justify-content: center; gap: 4px; height: 30px; align-items: flex-end; }
152
+ .bar { width: 5px; background: var(--accent-primary); animation: jump 1s infinite; border-radius: 2px; }
153
+ .bar:nth-child(2) { animation-delay: 0.1s; height: 60%; }
154
+ .bar:nth-child(3) { animation-delay: 0.2s; height: 80%; }
155
+ .bar:nth-child(4) { animation-delay: 0.3s; height: 50%; }
156
+ @keyframes jump { 0%, 100% { height: 20%; } 50% { height: 100%; } }
157
+
158
+ @keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
159
+
160
+ /* مخفی کردن المان‌های تکنیکال */
161
+ .hidden { display: none; }
162
+ </style>
163
+ </head>
164
+ <body>
165
+ <canvas id="music-canvas"></canvas>
166
+
167
+ <div class="container">
168
+ <header>
169
+ <div class="logo-box">
170
+ <svg width="40" height="40" 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>
171
+ </div>
172
+ <h1>استودیو موزیک ACE</h1>
173
+ <p class="subtitle">ساخت آهنگ کامل با هوش مصنوعی</p>
174
+ </header>
175
+
176
+ <!-- مرحله ۱: ایده -->
177
+ <div id="step1" class="card">
178
+ <div class="form-label">
179
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path></svg>
180
+ موضوع آهنگ چیه؟
181
+ </div>
182
+ <textarea id="ideaInput" placeholder="مثال: آهنگ تولد برای سمیرا، شاد و پرانرژی..."></textarea>
183
+ <button id="processBtn" class="btn-main" style="margin-top: 15px;">
184
+ <span>نوشتن متن و آهنگسازی</span>
185
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"></polyline></svg>
186
+ </button>
187
+ </div>
188
+
189
+ <!-- لودر -->
190
+ <div id="loader">
191
+ <div class="wave-bars">
192
+ <div class="bar"></div><div class="bar"></div><div class="bar"></div><div class="bar"></div><div class="bar"></div>
193
+ </div>
194
+ <p style="color: #718096; font-size: 0.9rem; margin-top: 10px;" id="loaderText">در حال پردازش...</p>
195
+ </div>
196
+
197
+ <!-- مرحله ۲: نمایش متن و ساخت آهنگ (مخفی) -->
198
+ <!-- ما این مرحله را اتوماتیک رد می‌کنیم یا به کاربر اجازه ویرایش می‌دهیم -->
199
+ <div id="step2" class="card hidden">
200
+ <div class="form-label">متن آماده شده (قابل ویرایش)</div>
201
+ <textarea id="generatedLyrics" style="height: 200px;"></textarea>
202
+ <textarea id="generatedPrompt" class="hidden"></textarea> <!-- پرامپت انگلیسی مخفی -->
203
+
204
+ <button id="generateAudioBtn" class="btn-main" style="margin-top: 15px;">
205
+ <span>ساخت نهایی آهنگ</span>
206
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>
207
+ </button>
208
+ </div>
209
+
210
+ <!-- مرحله ۳: نتیجه نهایی -->
211
+ <div id="finalResult" class="card">
212
+ <div class="player-header">
213
+ <div style="font-weight: 700; color: var(--success-color); display: flex; align-items: center; gap: 5px;">
214
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>
215
+ آهنگ آماده شد
216
+ </div>
217
+ <a id="downloadLink" href="#" style="color: var(--accent-primary); text-decoration: none; font-size: 0.9rem; font-weight: 600;">دانلود</a>
218
+ </div>
219
+
220
+ <div id="playerWrapper"></div>
221
+
222
+ <div class="form-label" style="margin-top: 20px; justify-content: center; color: #718096;">متن آهنگ</div>
223
+ <div class="lyrics-container" id="finalLyricsBox">
224
+ <!-- متن شعر اینجا قرار میگیره -->
225
+ </div>
226
+
227
+ <button onclick="location.reload()" class="btn-main btn-outline">ساخت آهنگ جدید</button>
228
+ </div>
229
+ </div>
230
+
231
+ <script>
232
+ const ACE_SPACE_URL = "https://ace-step-ace-step-v1-5.hf.space/";
233
+
234
+ // المان‌ها
235
+ const ideaInput = document.getElementById('ideaInput');
236
+ const processBtn = document.getElementById('processBtn');
237
+ const step1 = document.getElementById('step1');
238
+ const step2 = document.getElementById('step2');
239
+ const loader = document.getElementById('loader');
240
+ const loaderText = document.getElementById('loaderText');
241
+ const generatedLyrics = document.getElementById('generatedLyrics');
242
+ const generatedPrompt = document.getElementById('generatedPrompt');
243
+ const generateAudioBtn = document.getElementById('generateAudioBtn');
244
+ const finalResult = document.getElementById('finalResult');
245
+ const playerWrapper = document.getElementById('playerWrapper');
246
+ const finalLyricsBox = document.getElementById('finalLyricsBox');
247
+ const downloadLink = document.getElementById('downloadLink');
248
+
249
+ // مرحله ۱: تولید متن با جمینای
250
+ processBtn.addEventListener('click', async () => {
251
+ if (!ideaInput.value.trim()) return alert("لطفا موضوع آهنگ را بنویسید");
252
+
253
+ // انیمیشن UI
254
+ processBtn.disabled = true;
255
+ loader.style.display = 'block';
256
+ loaderText.innerText = "هوش مصنوعی در حال سرودن شعر و تنظیم آهنگ...";
257
+ step1.style.display = 'none';
258
+
259
+ try {
260
+ const response = await fetch('/api/refine', {
261
+ method: 'POST',
262
+ headers: {'Content-Type': 'application/json'},
263
+ body: JSON.stringify({ idea: ideaInput.value })
264
+ });
265
+
266
+ const data = await response.json();
267
+ if (data.error) throw new Error(data.error);
268
+
269
+ generatedLyrics.value = data.lyrics;
270
+ generatedPrompt.value = data.music_prompt;
271
+
272
+ // نمایش مرحله ۲ (ویرایش متن)
273
+ loader.style.display = 'none';
274
+ step2.style.display = 'block';
275
+ step2.classList.remove('hidden');
276
+
277
+ } catch (e) {
278
+ alert("خطا: " + e.message);
279
+ step1.style.display = 'block';
280
+ loader.style.display = 'none';
281
+ processBtn.disabled = false;
282
+ }
283
+ });
284
+
285
+ // مرحله ۲: ساخت آهنگ با ACE-Step
286
+ generateAudioBtn.addEventListener('click', async () => {
287
+ generateAudioBtn.disabled = true;
288
+ step2.style.display = 'none';
289
+ loader.style.display = 'block';
290
+ loaderText.innerText = "در حال ضبط استودیویی (ممکن است ۱ تا ۲ دقیقه طول بکشد)...";
291
+
292
+ try {
293
+ // فرمت کردن متن شعر برای نمایش زیباتر (هایلایت کردن تگ ها)
294
+ formatLyricsForDisplay(generatedLyrics.value);
295
+
296
+ const payload = [
297
+ "acestep-v15-turbo", "custom", null, "unknown",
298
+ generatedPrompt.value, // Prompt English
299
+ generatedLyrics.value, // Lyrics Persian
300
+ 0, "", "", "unknown",
301
+ 8, // Steps
302
+ 7, true, -1, null, -1, 1, null, null, 0, -1,
303
+ "Fill the audio semantic mask based on the given conditions:",
304
+ 1, "text2music", false, 0, 1, 3, "ode", "", "mp3", 0.85,
305
+ true, 2, 0, 0.9, "NO USER INPUT", true, true, true, null, false, true, false, false, 0.5, 8, null, [], false, null, null, null, null
306
+ ];
307
+
308
+ const session_hash = Math.random().toString(36).substring(2);
309
+
310
+ const joinResp = await fetch(`${ACE_SPACE_URL}gradio_api/queue/join`, {
311
+ method: 'POST',
312
+ headers: { 'Content-Type': 'application/json' },
313
+ body: JSON.stringify({ data: payload, fn_index: 77, session_hash })
314
+ });
315
+
316
+ if (!joinResp.ok) throw new Error('خطا در اتصال به سرور موزیک');
317
+
318
+ const eventSource = new EventSource(`${ACE_SPACE_URL}gradio_api/queue/data?session_hash=${session_hash}`);
319
+
320
+ eventSource.onmessage = (event) => {
321
+ const msg = JSON.parse(event.data);
322
+ if (msg.msg === 'process_starts') {
323
+ loaderText.innerText = "خواننده شروع به خواندن کرد...";
324
+ } else if (msg.msg === 'process_completed') {
325
+ eventSource.close();
326
+ loader.style.display = 'none';
327
+ handleAudioOutput(msg.output);
328
+ }
329
+ };
330
+
331
+ eventSource.onerror = () => {
332
+ throw new Error('قطع ارتباط با سرور.');
333
+ };
334
+
335
+ } catch (e) {
336
+ alert(e.message);
337
+ loader.style.display = 'none';
338
+ step2.style.display = 'block';
339
+ generateAudioBtn.disabled = false;
340
+ }
341
+ });
342
+
343
+ function handleAudioOutput(data) {
344
+ let audioUrl = null;
345
+ function traverse(obj) {
346
+ if (typeof obj === 'string' && obj.includes('/file=') && obj.endsWith('.mp3')) {
347
+ audioUrl = obj;
348
+ } else if (obj && typeof obj === 'object') {
349
+ if (obj.url && obj.url.endsWith('.mp3')) audioUrl = obj.url;
350
+ Object.values(obj).forEach(traverse);
351
+ }
352
+ }
353
+ traverse(data);
354
+
355
+ if (audioUrl) {
356
+ const fullUrl = audioUrl.startsWith('http') ? audioUrl : ACE_SPACE_URL.replace(/\/$/, '') + audioUrl;
357
+
358
+ playerWrapper.innerHTML = `<audio controls autoplay src="${fullUrl}"></audio>`;
359
+ downloadLink.href = fullUrl;
360
+
361
+ finalResult.style.display = 'block';
362
+ // اسکرول نرم به بالا
363
+ window.scrollTo({ top: 0, behavior: 'smooth' });
364
+ } else {
365
+ alert("فایل صوتی یافت نشد!");
366
+ step2.style.display = 'block';
367
+ }
368
+ }
369
+
370
+ function formatLyricsForDisplay(text) {
371
+ // این تابع تگ‌های [Intro] و غیره را پیدا کرده و استایل می‌دهد
372
+ let formatted = text.replace(/\[(.*?)\]/g, '<span class="lyrics-tag">[$1]</span>');
373
+ finalLyricsBox.innerHTML = formatted;
374
+ }
375
+
376
+ // انیمیشن ساده پس زمینه
377
+ const canvas = document.getElementById('music-canvas');
378
+ const ctx = canvas.getContext('2d');
379
+ let t = 0;
380
+
381
+ function resize() {
382
+ canvas.width = window.innerWidth;
383
+ canvas.height = 400;
384
+ }
385
+ window.addEventListener('resize', resize);
386
+ resize();
387
+
388
+ function anim() {
389
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
390
+ ctx.beginPath();
391
+ ctx.strokeStyle = "rgba(74, 108, 250, 0.1)";
392
+ ctx.lineWidth = 2;
393
+
394
+ for(let i=0; i<canvas.width; i+=20) {
395
+ ctx.moveTo(i, 0);
396
+ ctx.lineTo(i, Math.sin(i * 0.01 + t) * 50 + 100);
397
+ }
398
+ ctx.stroke();
399
+ t += 0.02;
400
+ requestAnimationFrame(anim);
401
+ }
402
+ anim();
403
+ </script>
404
+ </body>
405
+ </html>