Spaces:
Sleeping
Sleeping
Final Release: Premium Glassmorphism UI & Ansari Bilal Branding
Browse files
README.md
CHANGED
|
@@ -11,18 +11,26 @@ license: mit
|
|
| 11 |
short_description: Turn your feelings into AI-generated music
|
| 12 |
---
|
| 13 |
|
| 14 |
-
# 🎵 Emotion2Music AI
|
| 15 |
|
| 16 |
-
**
|
| 17 |
|
| 18 |
-
This
|
| 19 |
|
| 20 |
-
##
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Supported Emotions
|
| 28 |
|
|
|
|
| 11 |
short_description: Turn your feelings into AI-generated music
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# 🎵 Emotion2Music AI — Final Release
|
| 15 |
|
| 16 |
+
**Developed by [Ansari Bilal](https://ansaribilal.com)**
|
| 17 |
|
| 18 |
+
Turn your feelings into a cinematic musical experience. This premium application analyzes your complex emotional states and uses Meta's MusicGen to compose a custom soundtrack that resonates with your soul.
|
| 19 |
|
| 20 |
+
## ✨ Premium Features
|
| 21 |
|
| 22 |
+
- **Advanced Emotional Intelligence** — Uses DistilRoBERTa to detect 7 distinct emotional states with confidence visualization.
|
| 23 |
+
- **Glassmorphism UI** — High-end, responsive interface with deep blurs and mesh gradients.
|
| 24 |
+
- **Adaptive Duration** — Control your composition length (5s - 15s).
|
| 25 |
+
- **Pro Performance** — Built-in ZeroGPU support for near-instant (3s-5s) music generation on Hugging Face PRO.
|
| 26 |
+
- **Queue System** — Robust handling of multiple requests with real-time progress tracking.
|
| 27 |
+
|
| 28 |
+
## 🛠️ How It Works
|
| 29 |
+
|
| 30 |
+
1. **Express Yourself** — Describe your current state in the text area.
|
| 31 |
+
2. **AI Analysis** — The AI identifies your dominant emotion and creates a descriptive musical prompt.
|
| 32 |
+
3. **Pure Composition** — MusicGen generates High-Fidelity 32kHz audio matching the prompt.
|
| 33 |
+
4. **Instant Playback** — Listen and download your unique AI-generated track.
|
| 34 |
|
| 35 |
## Supported Emotions
|
| 36 |
|
app.py
CHANGED
|
@@ -208,98 +208,154 @@ else:
|
|
| 208 |
|
| 209 |
|
| 210 |
# ---------------------------------------------------------------------------
|
| 211 |
-
# Custom CSS for
|
| 212 |
# ---------------------------------------------------------------------------
|
| 213 |
CUSTOM_CSS = """
|
| 214 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
.gradio-container {
|
| 216 |
-
max-width:
|
| 217 |
margin: 0 auto !important;
|
|
|
|
|
|
|
| 218 |
}
|
| 219 |
|
| 220 |
-
/*
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
text-align: center;
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
-webkit-background-clip: text;
|
| 225 |
-webkit-text-fill-color: transparent;
|
| 226 |
-
|
| 227 |
-
font-size: 2.8em !important;
|
| 228 |
font-weight: 800 !important;
|
| 229 |
-
|
| 230 |
-
|
| 231 |
}
|
| 232 |
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
font-size: 1.
|
| 236 |
-
|
| 237 |
-
|
|
|
|
| 238 |
}
|
| 239 |
|
| 240 |
-
|
| 241 |
-
#
|
| 242 |
-
|
| 243 |
-
border: none !important;
|
| 244 |
-
color: white !important;
|
| 245 |
-
font-size: 1.1em !important;
|
| 246 |
font-weight: 600 !important;
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
transition: all 0.3s ease !important;
|
| 250 |
-
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
|
| 251 |
}
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
}
|
| 257 |
|
| 258 |
-
/*
|
| 259 |
#mood-input textarea {
|
| 260 |
-
|
| 261 |
-
border
|
| 262 |
-
border:
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
}
|
| 265 |
|
| 266 |
-
#
|
| 267 |
-
|
| 268 |
-
box-shadow: 0
|
| 269 |
}
|
| 270 |
|
| 271 |
-
/*
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
border: 1px solid rgba(102, 126, 234, 0.2) !important;
|
| 275 |
}
|
| 276 |
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
}
|
| 281 |
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
|
|
|
| 285 |
}
|
| 286 |
|
| 287 |
-
/*
|
| 288 |
-
#
|
| 289 |
-
|
|
|
|
|
|
|
|
|
|
| 290 |
}
|
| 291 |
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
| 295 |
}
|
| 296 |
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
text-align: center;
|
| 300 |
-
opacity: 0.5;
|
| 301 |
-
font-size: 0.85em !important;
|
| 302 |
-
margin-top: 20px !important;
|
| 303 |
}
|
| 304 |
"""
|
| 305 |
|
|
@@ -313,77 +369,79 @@ theme = gr.themes.Soft(
|
|
| 313 |
font=gr.themes.GoogleFont("Inter"),
|
| 314 |
)
|
| 315 |
|
| 316 |
-
with gr.Blocks(theme=theme, css=CUSTOM_CSS, title="Emotion2Music AI") as demo:
|
| 317 |
|
| 318 |
-
# --- Header ---
|
| 319 |
-
gr.
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
)
|
| 325 |
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
duration_slider = gr.Slider(
|
| 341 |
minimum=5,
|
| 342 |
maximum=15,
|
| 343 |
value=8,
|
| 344 |
step=1,
|
| 345 |
-
label="
|
| 346 |
elem_id="duration-slider",
|
| 347 |
)
|
| 348 |
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
)
|
| 355 |
-
|
| 356 |
-
# --- Examples ---
|
| 357 |
-
gr.Examples(
|
| 358 |
-
examples=[
|
| 359 |
-
["I'm so excited! I just got my dream job and I can't stop smiling!"],
|
| 360 |
-
["I feel really down today, nothing seems to go right..."],
|
| 361 |
-
["Something just jumped out at me and I screamed!"],
|
| 362 |
-
["I'm furious about the injustice I witnessed today."],
|
| 363 |
-
["I feel calm and content, just relaxing at home."],
|
| 364 |
-
["That food was absolutely revolting, I can't believe I tried it."],
|
| 365 |
-
["I feel hopeful but a little anxious about tomorrow."],
|
| 366 |
-
],
|
| 367 |
-
inputs=text_input,
|
| 368 |
-
label="💡 Try these examples",
|
| 369 |
-
)
|
| 370 |
-
|
| 371 |
-
gr.HTML("<hr style='border: 1px solid rgba(102, 126, 234, 0.15); margin: 20px 0;'>")
|
| 372 |
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
)
|
| 381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
audio_output = gr.Audio(
|
| 383 |
-
label="
|
| 384 |
type="numpy",
|
| 385 |
elem_id="audio-output",
|
|
|
|
| 386 |
)
|
|
|
|
| 387 |
gen_info = gr.Markdown(
|
| 388 |
value="",
|
| 389 |
elem_id="gen-info",
|
|
@@ -396,21 +454,22 @@ with gr.Blocks(theme=theme, css=CUSTOM_CSS, title="Emotion2Music AI") as demo:
|
|
| 396 |
outputs=[emotion_output, audio_output, gen_info],
|
| 397 |
)
|
| 398 |
|
| 399 |
-
# Also trigger on Enter key
|
| 400 |
text_input.submit(
|
| 401 |
fn=generate_music,
|
| 402 |
inputs=[text_input, duration_slider],
|
| 403 |
outputs=[emotion_output, audio_output, gen_info],
|
| 404 |
)
|
| 405 |
|
| 406 |
-
# --- Footer ---
|
| 407 |
-
gr.
|
| 408 |
-
"
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
|
|
|
|
|
|
| 414 |
|
| 415 |
# ---------------------------------------------------------------------------
|
| 416 |
# Launch
|
|
|
|
| 208 |
|
| 209 |
|
| 210 |
# ---------------------------------------------------------------------------
|
| 211 |
+
# Custom CSS for Premium Glassmorphism Theme
|
| 212 |
# ---------------------------------------------------------------------------
|
| 213 |
CUSTOM_CSS = """
|
| 214 |
+
/* Import modern font */
|
| 215 |
+
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
|
| 216 |
+
|
| 217 |
+
:root {
|
| 218 |
+
--primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
|
| 219 |
+
--glass-bg: rgba(255, 255, 255, 0.03);
|
| 220 |
+
--glass-border: rgba(255, 255, 255, 0.1);
|
| 221 |
+
--text-main: #f8fafc;
|
| 222 |
+
--text-muted: #94a3b8;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/* Base Container & Background */
|
| 226 |
.gradio-container {
|
| 227 |
+
max-width: 1100px !important;
|
| 228 |
margin: 0 auto !important;
|
| 229 |
+
background: transparent !important;
|
| 230 |
+
font-family: 'Space+Grotesk', sans-serif !important;
|
| 231 |
}
|
| 232 |
|
| 233 |
+
/* Mesh Gradient Background for the whole page */
|
| 234 |
+
body {
|
| 235 |
+
background-color: #05070a !important;
|
| 236 |
+
background-image:
|
| 237 |
+
radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%),
|
| 238 |
+
radial-gradient(at 50% 0%, hsla(225,39%,20%,1) 0, transparent 50%),
|
| 239 |
+
radial-gradient(at 100% 0%, hsla(339,49%,20%,1) 0, transparent 50%) !important;
|
| 240 |
+
background-attachment: fixed !important;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
/* Glassmorphism Cards */
|
| 244 |
+
.glass-card {
|
| 245 |
+
background: var(--glass-bg) !important;
|
| 246 |
+
backdrop-filter: blur(16px) !important;
|
| 247 |
+
-webkit-backdrop-filter: blur(16px) !important;
|
| 248 |
+
border: 1px solid var(--glass-border) !important;
|
| 249 |
+
border-radius: 24px !important;
|
| 250 |
+
padding: 20px !important;
|
| 251 |
+
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37) !important;
|
| 252 |
+
transition: transform 0.3s ease, box-shadow 0.3s ease !important;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.glass-card:hover {
|
| 256 |
+
box-shadow: 0 12px 48px 0 rgba(0, 0, 0, 0.5) !important;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
/* Branding & Typography */
|
| 260 |
+
#brand-header {
|
| 261 |
text-align: center;
|
| 262 |
+
padding: 40px 0;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
.main-title {
|
| 266 |
+
background: var(--primary-gradient);
|
| 267 |
-webkit-background-clip: text;
|
| 268 |
-webkit-text-fill-color: transparent;
|
| 269 |
+
font-size: 3.5rem !important;
|
|
|
|
| 270 |
font-weight: 800 !important;
|
| 271 |
+
letter-spacing: -0.05em !important;
|
| 272 |
+
margin-bottom: 8px !important;
|
| 273 |
}
|
| 274 |
|
| 275 |
+
.creator-tag {
|
| 276 |
+
color: var(--text-muted);
|
| 277 |
+
font-size: 1.1rem !important;
|
| 278 |
+
font-weight: 400 !important;
|
| 279 |
+
letter-spacing: 0.1em !important;
|
| 280 |
+
text-transform: uppercase;
|
| 281 |
}
|
| 282 |
|
| 283 |
+
.creator-link {
|
| 284 |
+
color: #a855f7 !important;
|
| 285 |
+
text-decoration: none !important;
|
|
|
|
|
|
|
|
|
|
| 286 |
font-weight: 600 !important;
|
| 287 |
+
border-bottom: 2px solid transparent;
|
| 288 |
+
transition: all 0.3s ease;
|
|
|
|
|
|
|
| 289 |
}
|
| 290 |
|
| 291 |
+
.creator-link:hover {
|
| 292 |
+
border-bottom: 2px solid #a855f7;
|
| 293 |
+
text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
|
| 294 |
}
|
| 295 |
|
| 296 |
+
/* Component Styling */
|
| 297 |
#mood-input textarea {
|
| 298 |
+
background: rgba(0, 0, 0, 0.2) !important;
|
| 299 |
+
border: 1px solid var(--glass-border) !important;
|
| 300 |
+
border-radius: 16px !important;
|
| 301 |
+
color: var(--text-main) !important;
|
| 302 |
+
font-size: 1.1rem !important;
|
| 303 |
+
padding: 16px !important;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
/* Primary Button */
|
| 307 |
+
#generate-btn {
|
| 308 |
+
background: var(--primary-gradient) !important;
|
| 309 |
+
border: none !important;
|
| 310 |
+
border-radius: 16px !important;
|
| 311 |
+
color: white !important;
|
| 312 |
+
font-weight: 700 !important;
|
| 313 |
+
font-size: 1.2rem !important;
|
| 314 |
+
padding: 16px 32px !important;
|
| 315 |
+
cursor: pointer;
|
| 316 |
+
box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3) !important;
|
| 317 |
+
transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
|
| 318 |
}
|
| 319 |
|
| 320 |
+
#generate-btn:hover {
|
| 321 |
+
transform: scale(1.02) translateY(-2px) !important;
|
| 322 |
+
box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5) !important;
|
| 323 |
}
|
| 324 |
|
| 325 |
+
/* Slider styling */
|
| 326 |
+
.slider-container {
|
| 327 |
+
padding-top: 20px !important;
|
|
|
|
| 328 |
}
|
| 329 |
|
| 330 |
+
/* Result visualization */
|
| 331 |
+
.emotion-bar-container {
|
| 332 |
+
margin-top: 10px !important;
|
| 333 |
}
|
| 334 |
|
| 335 |
+
/* Audio Player */
|
| 336 |
+
audio {
|
| 337 |
+
width: 100% !important;
|
| 338 |
+
filter: invert(1) hue-rotate(180deg) brightness(1.5);
|
| 339 |
}
|
| 340 |
|
| 341 |
+
/* Footer Styling */
|
| 342 |
+
#footer-area {
|
| 343 |
+
margin-top: 60px;
|
| 344 |
+
padding: 40px;
|
| 345 |
+
border-top: 1px solid var(--glass-border);
|
| 346 |
+
text-align: center;
|
| 347 |
}
|
| 348 |
|
| 349 |
+
.footer-link {
|
| 350 |
+
margin: 0 15px;
|
| 351 |
+
color: var(--text-muted) !important;
|
| 352 |
+
text-decoration: none !important;
|
| 353 |
+
font-size: 0.95rem;
|
| 354 |
+
transition: color 0.3s ease;
|
| 355 |
}
|
| 356 |
|
| 357 |
+
.footer-link:hover {
|
| 358 |
+
color: var(--text-main) !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
}
|
| 360 |
"""
|
| 361 |
|
|
|
|
| 369 |
font=gr.themes.GoogleFont("Inter"),
|
| 370 |
)
|
| 371 |
|
| 372 |
+
with gr.Blocks(theme=theme, css=CUSTOM_CSS, title="Emotion2Music AI — Final Release") as demo:
|
| 373 |
|
| 374 |
+
# --- Header Branding ---
|
| 375 |
+
with gr.Div(elem_id="brand-header"):
|
| 376 |
+
gr.HTML("""
|
| 377 |
+
<h1 class='main-title'>Emotion2Music AI</h1>
|
| 378 |
+
<p class='creator-tag'>Developed by <a href='https://ansaribilal.com' target='_blank' class='creator-link'>Ansari Bilal</a></p>
|
| 379 |
+
""")
|
|
|
|
| 380 |
|
| 381 |
+
# --- Layout Grid ---
|
| 382 |
+
with gr.Row():
|
| 383 |
+
# --- LEFT COLUMN: Input & Control ---
|
| 384 |
+
with gr.Column(scale=1, elem_classes="glass-card"):
|
| 385 |
+
gr.Markdown("### 🌑 Step 1: Mood Expression")
|
| 386 |
+
text_input = gr.Textbox(
|
| 387 |
+
label="",
|
| 388 |
+
placeholder="How is your soul feeling right now? Describe it in a sentence...",
|
| 389 |
+
lines=4,
|
| 390 |
+
elem_id="mood-input",
|
| 391 |
+
)
|
| 392 |
+
|
| 393 |
+
with gr.Div(elem_classes="slider-container"):
|
| 394 |
+
gr.Markdown("### ⏱️ Step 2: Duration")
|
| 395 |
duration_slider = gr.Slider(
|
| 396 |
minimum=5,
|
| 397 |
maximum=15,
|
| 398 |
value=8,
|
| 399 |
step=1,
|
| 400 |
+
label="",
|
| 401 |
elem_id="duration-slider",
|
| 402 |
)
|
| 403 |
|
| 404 |
+
generate_btn = gr.Button(
|
| 405 |
+
"✨ COMPOSING MUSIC",
|
| 406 |
+
variant="primary",
|
| 407 |
+
elem_id="generate-btn",
|
| 408 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
|
| 410 |
+
# Examples within the card
|
| 411 |
+
gr.Markdown("---")
|
| 412 |
+
gr.Markdown("### 💡 Suggestions")
|
| 413 |
+
gr.Examples(
|
| 414 |
+
examples=[
|
| 415 |
+
["A warm sunset over a quiet ocean, feeling peaceful."],
|
| 416 |
+
["Thunder crashing in the distance, heart racing with adrenaline."],
|
| 417 |
+
["Lost in a crowded city, feeling invisible yet hopeful."],
|
| 418 |
+
["Dancing in the rain like nobody is watching!"],
|
| 419 |
+
["The silence of an empty house, echoing with memories."]
|
| 420 |
+
],
|
| 421 |
+
inputs=text_input,
|
| 422 |
+
label="",
|
| 423 |
)
|
| 424 |
+
|
| 425 |
+
# --- RIGHT COLUMN: Results & Insights ---
|
| 426 |
+
with gr.Column(scale=1, elem_classes="glass-card"):
|
| 427 |
+
gr.Markdown("### 🧠 Step 3: AI Insights")
|
| 428 |
+
|
| 429 |
+
with gr.Div(elem_classes="emotion-bar-container"):
|
| 430 |
+
emotion_output = gr.Markdown(
|
| 431 |
+
value="*Analysis will appear here after detection...*",
|
| 432 |
+
elem_id="emotion-results",
|
| 433 |
+
)
|
| 434 |
+
|
| 435 |
+
gr.Markdown("---")
|
| 436 |
+
gr.Markdown("### 🔊 Step 4: Your Composition")
|
| 437 |
+
|
| 438 |
audio_output = gr.Audio(
|
| 439 |
+
label="",
|
| 440 |
type="numpy",
|
| 441 |
elem_id="audio-output",
|
| 442 |
+
interactive=False,
|
| 443 |
)
|
| 444 |
+
|
| 445 |
gen_info = gr.Markdown(
|
| 446 |
value="",
|
| 447 |
elem_id="gen-info",
|
|
|
|
| 454 |
outputs=[emotion_output, audio_output, gen_info],
|
| 455 |
)
|
| 456 |
|
|
|
|
| 457 |
text_input.submit(
|
| 458 |
fn=generate_music,
|
| 459 |
inputs=[text_input, duration_slider],
|
| 460 |
outputs=[emotion_output, audio_output, gen_info],
|
| 461 |
)
|
| 462 |
|
| 463 |
+
# --- Footer Branding ---
|
| 464 |
+
with gr.Div(elem_id="footer-area"):
|
| 465 |
+
gr.HTML(f"""
|
| 466 |
+
<p style='color: white; margin-bottom: 20px;'>© 2026 Ansari Bilal. All rights reserved.</p>
|
| 467 |
+
<div style='display: flex; justify-content: center; gap: 20px;'>
|
| 468 |
+
<a href='https://ansaribilal.com' target='_blank' class='footer-link'>Portfolio</a>
|
| 469 |
+
<a href='https://huggingface.co/Nick021402' target='_blank' class='footer-link'>HF Profile</a>
|
| 470 |
+
<a href='mailto:contact@ansaribilal.com' class='footer-link'>Contact</a>
|
| 471 |
+
</div>
|
| 472 |
+
""")
|
| 473 |
|
| 474 |
# ---------------------------------------------------------------------------
|
| 475 |
# Launch
|