Update index.html
Browse files- index.html +51 -26
index.html
CHANGED
|
@@ -161,9 +161,22 @@
|
|
| 161 |
border-bottom: 1px solid var(--panel-border);
|
| 162 |
}
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
.lyrics-container {
|
| 169 |
background: var(--input-bg);
|
|
@@ -294,8 +307,12 @@
|
|
| 294 |
<div class="player-header">
|
| 295 |
<div style="font-weight: 700; color: var(--success-color); display: flex; align-items: center; gap: 5px;">
|
| 296 |
<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>
|
| 297 |
-
آهنگ
|
| 298 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
</div>
|
| 300 |
|
| 301 |
<div id="playerWrapper"></div>
|
|
@@ -328,6 +345,7 @@
|
|
| 328 |
const finalResult = document.getElementById('finalResult');
|
| 329 |
const playerWrapper = document.getElementById('playerWrapper');
|
| 330 |
const finalLyricsBox = document.getElementById('finalLyricsBox');
|
|
|
|
| 331 |
|
| 332 |
// فعالسازی آکاردئون
|
| 333 |
const acc = document.getElementsByClassName("accordion");
|
|
@@ -384,7 +402,7 @@
|
|
| 384 |
}
|
| 385 |
});
|
| 386 |
|
| 387 |
-
// مرحله ۲: ساخت آهنگ
|
| 388 |
generateAudioBtn.addEventListener('click', async () => {
|
| 389 |
generateAudioBtn.disabled = true;
|
| 390 |
step2.style.display = 'none';
|
|
@@ -393,25 +411,24 @@
|
|
| 393 |
|
| 394 |
try {
|
| 395 |
formatLyricsForDisplay(generatedLyrics.value);
|
| 396 |
-
playerWrapper.innerHTML = '';
|
| 397 |
|
| 398 |
-
// ساخت Payload با تمام تنظیمات کاربر
|
| 399 |
const payload = [
|
| 400 |
-
getVal('model_select'),
|
| 401 |
"custom", null, "unknown",
|
| 402 |
-
generatedPrompt.value,
|
| 403 |
-
generatedLyrics.value,
|
| 404 |
0, "", "", "unknown",
|
| 405 |
-
getNum('steps_input'),
|
| 406 |
-
getNum('cfg_input'),
|
| 407 |
true,
|
| 408 |
-
getNum('seed_input'),
|
| 409 |
null, -1,
|
| 410 |
-
getNum('batch_size'),
|
| 411 |
null, null, 0, -1,
|
| 412 |
"Fill the audio semantic mask based on the given conditions:",
|
| 413 |
1, "text2music", false, 0, 1, 3, "ode", "", "mp3", 0.85,
|
| 414 |
-
getChk('think_checkbox'),
|
| 415 |
2, 0, 0.9, "NO USER INPUT", true, true, true, null, false, true, false, false, 0.5, 8, null, [], false, null, null, null, null
|
| 416 |
];
|
| 417 |
|
|
@@ -451,21 +468,30 @@
|
|
| 451 |
});
|
| 452 |
|
| 453 |
function handleAudioOutput(data) {
|
| 454 |
-
|
|
|
|
|
|
|
| 455 |
|
| 456 |
function addAudio(url) {
|
| 457 |
const fullUrl = url.startsWith('http') ? url : ACE_SPACE_URL.replace(/\/$/, '') + url;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
const div = document.createElement('div');
|
| 459 |
div.className = 'audio-item';
|
| 460 |
-
div.innerHTML = `
|
| 461 |
-
<div style="font-size:0.9em; margin-bottom:5px; color:#555;">🎵 خروجی آهنگ</div>
|
| 462 |
-
<audio controls src="${fullUrl}"></audio>
|
| 463 |
-
<div style="text-align:left; margin-top:5px;">
|
| 464 |
-
<a href="${fullUrl}" target="_blank" style="color:var(--accent-primary); font-size:0.9em;">دانلود فایل</a>
|
| 465 |
-
</div>
|
| 466 |
-
`;
|
| 467 |
playerWrapper.appendChild(div);
|
| 468 |
-
found = true;
|
| 469 |
}
|
| 470 |
|
| 471 |
function traverse(obj) {
|
|
@@ -478,7 +504,7 @@
|
|
| 478 |
}
|
| 479 |
traverse(data);
|
| 480 |
|
| 481 |
-
if (
|
| 482 |
finalResult.style.display = 'block';
|
| 483 |
window.scrollTo({ top: 0, behavior: 'smooth' });
|
| 484 |
} else {
|
|
@@ -492,7 +518,6 @@
|
|
| 492 |
finalLyricsBox.innerHTML = formatted;
|
| 493 |
}
|
| 494 |
|
| 495 |
-
// انیمیشن پسزمینه
|
| 496 |
const canvas = document.getElementById('music-canvas');
|
| 497 |
const ctx = canvas.getContext('2d');
|
| 498 |
let t = 0;
|
|
|
|
| 161 |
border-bottom: 1px solid var(--panel-border);
|
| 162 |
}
|
| 163 |
|
| 164 |
+
/* استایل دکمه دانلود در هدر */
|
| 165 |
+
#mainDownloadLink {
|
| 166 |
+
background-color: rgba(74, 108, 250, 0.1);
|
| 167 |
+
color: var(--accent-primary);
|
| 168 |
+
text-decoration: none;
|
| 169 |
+
font-size: 0.9rem;
|
| 170 |
+
font-weight: 700;
|
| 171 |
+
padding: 8px 16px;
|
| 172 |
+
border-radius: 10px;
|
| 173 |
+
transition: 0.2s;
|
| 174 |
+
display: none; /* تا زمان آماده شدن مخفی است */
|
| 175 |
+
}
|
| 176 |
+
#mainDownloadLink:hover { background-color: rgba(74, 108, 250, 0.2); }
|
| 177 |
+
|
| 178 |
+
.audio-item { margin-bottom: 10px; }
|
| 179 |
+
audio { width: 100%; height: 45px; border-radius: 20px; margin-top: 5px; }
|
| 180 |
|
| 181 |
.lyrics-container {
|
| 182 |
background: var(--input-bg);
|
|
|
|
| 307 |
<div class="player-header">
|
| 308 |
<div style="font-weight: 700; color: var(--success-color); display: flex; align-items: center; gap: 5px;">
|
| 309 |
<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>
|
| 310 |
+
آهنگ آماده شد
|
| 311 |
</div>
|
| 312 |
+
<!-- دکمه دانلود اینجا قرار گرفت -->
|
| 313 |
+
<a id="mainDownloadLink" href="#" target="_blank" download>
|
| 314 |
+
دانلود آهنگ 📥
|
| 315 |
+
</a>
|
| 316 |
</div>
|
| 317 |
|
| 318 |
<div id="playerWrapper"></div>
|
|
|
|
| 345 |
const finalResult = document.getElementById('finalResult');
|
| 346 |
const playerWrapper = document.getElementById('playerWrapper');
|
| 347 |
const finalLyricsBox = document.getElementById('finalLyricsBox');
|
| 348 |
+
const mainDownloadLink = document.getElementById('mainDownloadLink');
|
| 349 |
|
| 350 |
// فعالسازی آکاردئون
|
| 351 |
const acc = document.getElementsByClassName("accordion");
|
|
|
|
| 402 |
}
|
| 403 |
});
|
| 404 |
|
| 405 |
+
// مرحله ۲: ساخت آهنگ
|
| 406 |
generateAudioBtn.addEventListener('click', async () => {
|
| 407 |
generateAudioBtn.disabled = true;
|
| 408 |
step2.style.display = 'none';
|
|
|
|
| 411 |
|
| 412 |
try {
|
| 413 |
formatLyricsForDisplay(generatedLyrics.value);
|
| 414 |
+
playerWrapper.innerHTML = '';
|
| 415 |
|
|
|
|
| 416 |
const payload = [
|
| 417 |
+
getVal('model_select'),
|
| 418 |
"custom", null, "unknown",
|
| 419 |
+
generatedPrompt.value,
|
| 420 |
+
generatedLyrics.value,
|
| 421 |
0, "", "", "unknown",
|
| 422 |
+
getNum('steps_input'),
|
| 423 |
+
getNum('cfg_input'),
|
| 424 |
true,
|
| 425 |
+
getNum('seed_input'),
|
| 426 |
null, -1,
|
| 427 |
+
getNum('batch_size'),
|
| 428 |
null, null, 0, -1,
|
| 429 |
"Fill the audio semantic mask based on the given conditions:",
|
| 430 |
1, "text2music", false, 0, 1, 3, "ode", "", "mp3", 0.85,
|
| 431 |
+
getChk('think_checkbox'),
|
| 432 |
2, 0, 0.9, "NO USER INPUT", true, true, true, null, false, true, false, false, 0.5, 8, null, [], false, null, null, null, null
|
| 433 |
];
|
| 434 |
|
|
|
|
| 468 |
});
|
| 469 |
|
| 470 |
function handleAudioOutput(data) {
|
| 471 |
+
// استفاده از Set برای جلوگیری از تکرار فایل یکسان
|
| 472 |
+
const processedUrls = new Set();
|
| 473 |
+
let hasResult = false;
|
| 474 |
|
| 475 |
function addAudio(url) {
|
| 476 |
const fullUrl = url.startsWith('http') ? url : ACE_SPACE_URL.replace(/\/$/, '') + url;
|
| 477 |
+
|
| 478 |
+
// اگر این لینک قبلاً اضافه شده، دوباره اضافه نکن
|
| 479 |
+
if (processedUrls.has(fullUrl)) return;
|
| 480 |
+
processedUrls.add(fullUrl);
|
| 481 |
+
|
| 482 |
+
hasResult = true;
|
| 483 |
+
|
| 484 |
+
// اگر اولین آهنگ است، دکمه دانلود اصلی را آپدیت کن
|
| 485 |
+
if (processedUrls.size === 1) {
|
| 486 |
+
mainDownloadLink.href = fullUrl;
|
| 487 |
+
mainDownloadLink.style.display = 'inline-block';
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
// ساخت پلیر
|
| 491 |
const div = document.createElement('div');
|
| 492 |
div.className = 'audio-item';
|
| 493 |
+
div.innerHTML = `<audio controls src="${fullUrl}"></audio>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 494 |
playerWrapper.appendChild(div);
|
|
|
|
| 495 |
}
|
| 496 |
|
| 497 |
function traverse(obj) {
|
|
|
|
| 504 |
}
|
| 505 |
traverse(data);
|
| 506 |
|
| 507 |
+
if (hasResult) {
|
| 508 |
finalResult.style.display = 'block';
|
| 509 |
window.scrollTo({ top: 0, behavior: 'smooth' });
|
| 510 |
} else {
|
|
|
|
| 518 |
finalLyricsBox.innerHTML = formatted;
|
| 519 |
}
|
| 520 |
|
|
|
|
| 521 |
const canvas = document.getElementById('music-canvas');
|
| 522 |
const ctx = canvas.getContext('2d');
|
| 523 |
let t = 0;
|