Update index.html
Browse files- index.html +271 -221
index.html
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 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>استودیو موزیک
|
| 7 |
-
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;
|
| 8 |
<style>
|
| 9 |
:root {
|
| 10 |
--app-font: 'Vazirmatn', sans-serif;
|
|
@@ -16,215 +16,216 @@
|
|
| 16 |
--text-primary: #1A202C;
|
| 17 |
--text-secondary: #626F86;
|
| 18 |
--accent-primary: #4A6CFA;
|
| 19 |
-
--accent-glow: rgba(74, 108, 250, 0.
|
| 20 |
-
--
|
| 21 |
-
--radius-card:
|
| 22 |
-
--radius-
|
| 23 |
}
|
| 24 |
|
| 25 |
-
|
| 26 |
-
.container { max-width: 600px; width: 100%; position: relative; z-index: 2; }
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
display: inline-block; margin-bottom: 10px;
|
| 40 |
-
}
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
/* تنظیمات پیشرفته (کشویی) */
|
| 59 |
-
.settings-toggle {
|
| 60 |
-
display: flex; align-items: center; gap: 8px; cursor: pointer;
|
| 61 |
-
color: var(--text-secondary); font-size: 0.9rem; font-weight: 600;
|
| 62 |
-
margin-top: 1rem; padding: 10px; border-radius: 10px;
|
| 63 |
-
transition: background 0.2s; user-select: none;
|
| 64 |
}
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
}
|
| 73 |
-
.settings-panel.open { max-height: 300px; border: 1px solid var(--input-border); }
|
| 74 |
|
| 75 |
-
.
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--input-border);
|
| 79 |
-
background: #fff; font-family: inherit; font-size: 0.9rem; outline: none;
|
| 80 |
}
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
font-size: 1.1rem; font-weight: 700; cursor: pointer;
|
| 88 |
display: flex; justify-content: center; align-items: center; gap: 10px;
|
| 89 |
-
box-shadow: 0
|
| 90 |
-
transition:
|
| 91 |
-
}
|
| 92 |
-
.btn-alpha:hover { transform: translateY(-3px); box-shadow: 0 15px 30px -5px var(--accent-glow); }
|
| 93 |
-
.btn-alpha:active { transform: scale(0.98); }
|
| 94 |
-
|
| 95 |
-
/* لودر خفن (Cyberpunk Style) */
|
| 96 |
-
#loaderOverlay {
|
| 97 |
-
display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
|
| 98 |
-
background: rgba(255, 255, 255, 0.95); z-index: 100;
|
| 99 |
-
flex-direction: column; justify-content: center; align-items: center;
|
| 100 |
-
backdrop-filter: blur(10px);
|
| 101 |
}
|
| 102 |
-
|
| 103 |
-
.
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
.scanner::before, .scanner::after {
|
| 109 |
-
content: ''; position: absolute; border-radius: 50%;
|
| 110 |
-
border: 2px solid transparent; border-top-color: var(--accent-primary); border-bottom-color: var(--accent-primary);
|
| 111 |
-
animation: spin 3s linear infinite;
|
| 112 |
}
|
| 113 |
-
.
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
.
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
}
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
}
|
| 126 |
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
.player-container {
|
| 138 |
-
background: #F1F5F9; padding: 20px; border-radius: 20px; margin-bottom: 20px;
|
| 139 |
-
display: flex; align-items: center; justify-content: center;
|
| 140 |
}
|
| 141 |
-
audio { width: 100%; height: 45px; border-radius: 30px; }
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
}
|
| 149 |
-
.
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
-
|
|
|
|
| 152 |
</style>
|
| 153 |
</head>
|
| 154 |
<body>
|
|
|
|
| 155 |
|
| 156 |
<div class="container">
|
| 157 |
-
<header>
|
| 158 |
-
<
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
| 160 |
</header>
|
| 161 |
|
| 162 |
-
<!--
|
| 163 |
-
<div id="
|
| 164 |
-
<
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
<div class="settings-toggle" onclick="toggleSettings()">
|
| 168 |
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>
|
| 169 |
-
تنظیمات پیشرفته
|
| 170 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
<label>مدل هوش مصنوعی</label>
|
| 177 |
-
<select id="modelSelector">
|
| 178 |
-
<option value="acestep-v15-turbo">Alpha Turbo (سریع)</option>
|
| 179 |
-
<option value="acestep-v15-turbo-shift3">Alpha Pro (دقیق)</option>
|
| 180 |
-
</select>
|
| 181 |
-
</div>
|
| 182 |
-
<div class="setting-item">
|
| 183 |
-
<label>کیفیت (Steps)</label>
|
| 184 |
-
<input type="number" id="steps" value="8" min="4" max="20">
|
| 185 |
-
</div>
|
| 186 |
-
<div class="setting-item">
|
| 187 |
-
<label>مدت زمان (ثانیه)</label>
|
| 188 |
-
<input type="number" id="duration" value="60" disabled style="opacity: 0.6; cursor: not-allowed;" title="توسط هوش مصنوعی تعیین میشود">
|
| 189 |
-
</div>
|
| 190 |
-
<div class="setting-item">
|
| 191 |
-
<label>تنوع (Seed)</label>
|
| 192 |
-
<input type="text" id="seed" value="-1" placeholder="-1 تصادفی">
|
| 193 |
-
</div>
|
| 194 |
-
</div>
|
| 195 |
</div>
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
</button>
|
| 201 |
</div>
|
| 202 |
|
| 203 |
-
<!-- نتیجه نهایی -->
|
| 204 |
-
<div id="
|
| 205 |
-
<div class="
|
| 206 |
-
<div
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
| 208 |
</div>
|
| 209 |
|
| 210 |
-
<div
|
| 211 |
-
<!-- پلیر اینجا قرار میگیرد -->
|
| 212 |
-
</div>
|
| 213 |
|
| 214 |
-
<div style="
|
| 215 |
-
<div class="lyrics-
|
|
|
|
|
|
|
| 216 |
|
| 217 |
-
<button onclick="location.reload()" class="btn-
|
| 218 |
-
</div>
|
| 219 |
-
|
| 220 |
-
</div>
|
| 221 |
-
|
| 222 |
-
<!-- انیمیشن لودینگ خفن -->
|
| 223 |
-
<div id="loaderOverlay">
|
| 224 |
-
<div class="scanner">
|
| 225 |
-
<div class="core-pulse"></div>
|
| 226 |
</div>
|
| 227 |
-
<div class="loading-text" id="loadingStatus">در حال آنالیز ایده...</div>
|
| 228 |
</div>
|
| 229 |
|
| 230 |
<script>
|
|
@@ -232,56 +233,73 @@
|
|
| 232 |
|
| 233 |
// المانها
|
| 234 |
const ideaInput = document.getElementById('ideaInput');
|
| 235 |
-
const
|
| 236 |
-
const
|
| 237 |
-
const
|
| 238 |
-
const
|
| 239 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
const playerWrapper = document.getElementById('playerWrapper');
|
| 241 |
-
const
|
| 242 |
const downloadLink = document.getElementById('downloadLink');
|
| 243 |
|
| 244 |
-
//
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
// شروع فرآیند
|
| 254 |
-
inputSection.style.display = 'none';
|
| 255 |
-
loader.style.display = 'flex';
|
| 256 |
-
loadingStatus.innerText = "هوش مصنوعی آلفا در حال نوشتن شعر...";
|
| 257 |
|
| 258 |
try {
|
| 259 |
-
|
| 260 |
-
const refineResponse = 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
|
| 267 |
if (data.error) throw new Error(data.error);
|
| 268 |
|
| 269 |
-
|
| 270 |
-
|
| 271 |
|
| 272 |
-
//
|
| 273 |
-
|
|
|
|
|
|
|
| 274 |
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
|
| 280 |
const payload = [
|
| 281 |
-
|
| 282 |
-
|
|
|
|
| 283 |
0, "", "", "unknown",
|
| 284 |
-
|
|
|
|
| 285 |
"Fill the audio semantic mask based on the given conditions:",
|
| 286 |
1, "text2music", false, 0, 1, 3, "ode", "", "mp3", 0.85,
|
| 287 |
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
|
|
@@ -295,34 +313,34 @@
|
|
| 295 |
body: JSON.stringify({ data: payload, fn_index: 77, session_hash })
|
| 296 |
});
|
| 297 |
|
| 298 |
-
if (!joinResp.ok) throw new Error('خطا در اتصال به سرور');
|
| 299 |
|
| 300 |
const eventSource = new EventSource(`${ACE_SPACE_URL}gradio_api/queue/data?session_hash=${session_hash}`);
|
| 301 |
|
| 302 |
eventSource.onmessage = (event) => {
|
| 303 |
const msg = JSON.parse(event.data);
|
| 304 |
-
|
| 305 |
if (msg.msg === 'process_starts') {
|
| 306 |
-
|
| 307 |
} else if (msg.msg === 'process_completed') {
|
| 308 |
eventSource.close();
|
| 309 |
loader.style.display = 'none';
|
| 310 |
-
|
| 311 |
}
|
| 312 |
};
|
| 313 |
-
|
| 314 |
eventSource.onerror = () => {
|
| 315 |
-
throw new Error('قطع ارتباط.');
|
| 316 |
};
|
| 317 |
|
| 318 |
} catch (e) {
|
| 319 |
-
alert(
|
| 320 |
loader.style.display = 'none';
|
| 321 |
-
|
|
|
|
| 322 |
}
|
| 323 |
});
|
| 324 |
|
| 325 |
-
function
|
| 326 |
let audioUrl = null;
|
| 327 |
function traverse(obj) {
|
| 328 |
if (typeof obj === 'string' && obj.includes('/file=') && obj.endsWith('.mp3')) {
|
|
@@ -332,7 +350,7 @@
|
|
| 332 |
Object.values(obj).forEach(traverse);
|
| 333 |
}
|
| 334 |
}
|
| 335 |
-
traverse(
|
| 336 |
|
| 337 |
if (audioUrl) {
|
| 338 |
const fullUrl = audioUrl.startsWith('http') ? audioUrl : ACE_SPACE_URL.replace(/\/$/, '') + audioUrl;
|
|
@@ -340,16 +358,48 @@
|
|
| 340 |
playerWrapper.innerHTML = `<audio controls autoplay src="${fullUrl}"></audio>`;
|
| 341 |
downloadLink.href = fullUrl;
|
| 342 |
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
resultCard.style.display = 'block';
|
| 348 |
} else {
|
| 349 |
-
alert("
|
| 350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
}
|
|
|
|
|
|
|
|
|
|
| 352 |
}
|
|
|
|
| 353 |
</script>
|
| 354 |
</body>
|
| 355 |
</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;
|
|
|
|
| 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>
|
|
|
|
| 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
|
|
|
|
| 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')) {
|
|
|
|
| 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;
|
|
|
|
| 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>
|