CodeAntidote commited on
Commit
8d738dc
·
verified ·
1 Parent(s): ef36e43

Fix Gradio 6 dark theme and star background

Browse files
Files changed (1) hide show
  1. app.py +654 -0
app.py ADDED
@@ -0,0 +1,654 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Kids Rhyme Studio: simple, four-language Gradio app."""
2
+
3
+ # UI_BUILD: dark-v3
4
+
5
+ from audio_engine import make_sung_song
6
+ from dataclasses import asdict
7
+ import gradio as gr
8
+ from rhyme_engine import parse_request, validate_lyric_for_audio, write_rhyme
9
+ from themes import THEME_CHOICES
10
+
11
+
12
+ THEME = gr.themes.Base().set(
13
+ body_background_fill="#07152f",
14
+ body_background_fill_dark="#07152f",
15
+ body_text_color="#f7fbff",
16
+ body_text_color_dark="#f7fbff",
17
+ background_fill_primary="#07152f",
18
+ background_fill_primary_dark="#07152f",
19
+ background_fill_secondary="#10264a",
20
+ background_fill_secondary_dark="#10264a",
21
+ block_background_fill="#10264a",
22
+ block_background_fill_dark="#10264a",
23
+ block_border_color="#294b78",
24
+ block_border_color_dark="#294b78",
25
+ block_label_background_fill="#ff4f9a",
26
+ block_label_background_fill_dark="#ff4f9a",
27
+ block_label_text_color="#ffffff",
28
+ block_label_text_color_dark="#ffffff",
29
+ block_title_text_color="#ffffff",
30
+ block_title_text_color_dark="#ffffff",
31
+ input_background_fill="#f8fbff",
32
+ input_background_fill_dark="#f8fbff",
33
+ input_text_weight="500",
34
+ input_placeholder_color="#7d8da3",
35
+ input_placeholder_color_dark="#7d8da3",
36
+ panel_background_fill="#10264a",
37
+ panel_background_fill_dark="#10264a",
38
+ accordion_text_color="#f7fbff",
39
+ accordion_text_color_dark="#f7fbff",
40
+ button_primary_background_fill="#ff4f9a",
41
+ button_primary_background_fill_dark="#ff4f9a",
42
+ button_primary_text_color="#ffffff",
43
+ button_primary_text_color_dark="#ffffff",
44
+ button_secondary_background_fill="#65c7ff",
45
+ button_secondary_background_fill_dark="#65c7ff",
46
+ button_secondary_text_color="#08213e",
47
+ button_secondary_text_color_dark="#08213e",
48
+ )
49
+
50
+
51
+ CSS = r"""
52
+ /* ==========================================================
53
+ Kids Rhyme Studio — midnight playground theme
54
+ High contrast, kid-friendly, and readable in light/dark OS modes.
55
+ ========================================================== */
56
+
57
+ :root {
58
+ --kids-bg: #07152f;
59
+ --kids-bg-2: #0a1d3d;
60
+ --kids-card: #10264a;
61
+ --kids-card-2: #142d56;
62
+ --kids-ink: #f7fbff;
63
+ --kids-muted: #b9c8df;
64
+ --kids-pink: #ff4f9a;
65
+ --kids-pink-2: #ff77b3;
66
+ --kids-yellow: #ffd75e;
67
+ --kids-blue: #65c7ff;
68
+ --kids-mint: #7ce6c1;
69
+ --kids-border: rgba(165, 194, 235, .22);
70
+ --kids-input-ink: #15233b;
71
+ }
72
+
73
+ html, body {
74
+ min-height: 100vh !important;
75
+ margin: 0 !important;
76
+ background: radial-gradient(ellipse at 50% 0%, #0d2350 0%, #07152f 45%, #030812 100%) fixed !important;
77
+ color: var(--kids-ink) !important;
78
+ }
79
+
80
+ body,
81
+ gradio-app,
82
+ #root,
83
+ #root > div,
84
+ main,
85
+ .app,
86
+ .gradio-container,
87
+ .gradio-container .main,
88
+ .gradio-container .contain {
89
+ background: transparent !important;
90
+ background-color: transparent !important;
91
+ color: var(--kids-ink) !important;
92
+ }
93
+
94
+
95
+ .gradio-container {
96
+ max-width: 1180px !important;
97
+ margin: 0 auto !important;
98
+ padding: 28px 20px 40px !important;
99
+ font-family: Inter, ui-rounded, "Nunito", system-ui, -apple-system, BlinkMacSystemFont,
100
+ "Segoe UI", sans-serif !important;
101
+ }
102
+
103
+ /* Hero banner */
104
+ #hero {
105
+ position: relative;
106
+ overflow: hidden;
107
+ background:
108
+ radial-gradient(circle at 0% 0%, rgba(255, 79, 154, .24), transparent 28%),
109
+ radial-gradient(circle at 100% 100%, rgba(101, 199, 255, .22), transparent 27%),
110
+ linear-gradient(135deg, #17366a 0%, #214a82 54%, #1c3e70 100%);
111
+ border: 1px solid rgba(174, 208, 255, .28);
112
+ border-radius: 30px;
113
+ padding: 60px 34px 36px;
114
+ margin: 4px 0 18px;
115
+ text-align: center;
116
+ box-shadow: 0 22px 55px rgba(0, 0, 0, .28);
117
+ }
118
+
119
+ #hero:before,
120
+ #hero:after {
121
+ content: "";
122
+ position: absolute;
123
+ border-radius: 999px;
124
+ pointer-events: none;
125
+ }
126
+
127
+ #hero:before {
128
+ width: 155px;
129
+ height: 155px;
130
+ background: rgba(255, 97, 169, .16);
131
+ left: -52px;
132
+ top: -54px;
133
+ }
134
+
135
+ #hero:after {
136
+ width: 135px;
137
+ height: 135px;
138
+ background: rgba(89, 198, 255, .16);
139
+ right: -45px;
140
+ bottom: -50px;
141
+ }
142
+
143
+ #hero-copyright {
144
+ position: absolute;
145
+ z-index: 3;
146
+ top: 18px;
147
+ left: 24px;
148
+ color: #ffffff !important;
149
+ font-size: 14px;
150
+ font-weight: 900;
151
+ letter-spacing: .04em;
152
+ }
153
+
154
+ #hero-badge {
155
+ position: absolute;
156
+ z-index: 3;
157
+ top: 14px;
158
+ right: 20px;
159
+ display: inline-flex;
160
+ align-items: center;
161
+ gap: 6px;
162
+ background: rgba(255, 215, 94, .14);
163
+ border: 1px solid rgba(255, 224, 127, .55);
164
+ color: #ffe792 !important;
165
+ border-radius: 999px;
166
+ padding: 8px 13px;
167
+ font-size: 13px;
168
+ font-weight: 800;
169
+ white-space: nowrap;
170
+ }
171
+
172
+ #hero h1 {
173
+ position: relative;
174
+ z-index: 2;
175
+ font-size: clamp(2.3rem, 5vw, 4rem);
176
+ line-height: 1.04;
177
+ margin: 0 0 12px;
178
+ color: #ffffff !important;
179
+ letter-spacing: -.04em;
180
+ text-shadow: 0 3px 18px rgba(0, 0, 0, .20);
181
+ }
182
+
183
+ #hero p {
184
+ position: relative;
185
+ z-index: 2;
186
+ max-width: 760px;
187
+ margin: 0 auto;
188
+ color: #e5efff !important;
189
+ font-size: clamp(1rem, 2vw, 1.18rem);
190
+ line-height: 1.6;
191
+ }
192
+
193
+ /* Three easy steps */
194
+ #steps {
195
+ display: flex;
196
+ justify-content: center;
197
+ align-items: center;
198
+ gap: 9px;
199
+ flex-wrap: wrap;
200
+ margin: 10px 0 24px;
201
+ }
202
+
203
+ .step-pill {
204
+ display: inline-flex;
205
+ align-items: center;
206
+ gap: 6px;
207
+ padding: 9px 13px;
208
+ border-radius: 999px;
209
+ background: #102b52;
210
+ border: 1px solid rgba(167, 201, 250, .20);
211
+ color: #eef6ff !important;
212
+ font-size: 13px;
213
+ font-weight: 800;
214
+ box-shadow: 0 8px 18px rgba(0, 0, 0, .16);
215
+ }
216
+
217
+ .step-arrow {
218
+ color: #7ebce8 !important;
219
+ font-weight: 900;
220
+ }
221
+
222
+ /* Main cards */
223
+ .studio-card {
224
+ background: linear-gradient(180deg, #10264a 0%, #0f2344 100%) !important;
225
+ border: 1px solid var(--kids-border) !important;
226
+ border-radius: 25px !important;
227
+ padding: 19px !important;
228
+ box-shadow: 0 18px 38px rgba(0, 0, 0, .22) !important;
229
+ }
230
+
231
+ .card-title {
232
+ margin: 0 0 5px;
233
+ color: #ffffff !important;
234
+ font-size: 19px;
235
+ font-weight: 900;
236
+ }
237
+
238
+ .card-subtitle {
239
+ margin: 0 0 14px;
240
+ color: var(--kids-muted) !important;
241
+ font-size: 13px;
242
+ line-height: 1.5;
243
+ }
244
+
245
+ /* Gradio text and blocks */
246
+ .gradio-container .block,
247
+ .gradio-container .form,
248
+ .gradio-container .wrap,
249
+ .gradio-container .secondary-wrap,
250
+ .gradio-container .panel,
251
+ .gradio-container .container {
252
+ color: var(--kids-ink) !important;
253
+ }
254
+
255
+ .gradio-container label,
256
+ .gradio-container .label-wrap,
257
+ .gradio-container .label-wrap span {
258
+ color: #f7fbff !important;
259
+ font-weight: 750 !important;
260
+ }
261
+
262
+ .gradio-container .info {
263
+ color: #aebfd8 !important;
264
+ }
265
+
266
+ /* Inputs stay light for maximum readability */
267
+ .gradio-container input,
268
+ .gradio-container textarea,
269
+ .gradio-container select {
270
+ background: #f8fbff !important;
271
+ color: var(--kids-input-ink) !important;
272
+ border: 1px solid #bcd1ec !important;
273
+ border-radius: 14px !important;
274
+ box-shadow: none !important;
275
+ }
276
+
277
+ .gradio-container input::placeholder,
278
+ .gradio-container textarea::placeholder {
279
+ color: #7d8da3 !important;
280
+ opacity: 1 !important;
281
+ }
282
+
283
+ /* Dropdown controls */
284
+ .gradio-container [role="listbox"],
285
+ .gradio-container [role="combobox"] {
286
+ color: var(--kids-input-ink) !important;
287
+ }
288
+
289
+ /* Rhyme editor */
290
+ #lyrics textarea {
291
+ min-height: 330px !important;
292
+ line-height: 1.8 !important;
293
+ font-size: 1.04rem !important;
294
+ background: #fbfdff !important;
295
+ color: #17243a !important;
296
+ }
297
+
298
+ /* Buttons */
299
+ #make-rhyme,
300
+ #make-audio {
301
+ min-height: 54px !important;
302
+ border-radius: 16px !important;
303
+ font-weight: 900 !important;
304
+ font-size: 1.04rem !important;
305
+ transition: transform .15s ease, box-shadow .15s ease !important;
306
+ }
307
+
308
+ #make-rhyme {
309
+ background: linear-gradient(135deg, #ff3e91, #ff6dad) !important;
310
+ border: 0 !important;
311
+ color: #ffffff !important;
312
+ box-shadow: 0 10px 22px rgba(255, 62, 145, .26) !important;
313
+ }
314
+
315
+ #make-audio {
316
+ background: linear-gradient(135deg, #55c1ff, #78d0ff) !important;
317
+ border: 0 !important;
318
+ color: #08213e !important;
319
+ box-shadow: 0 10px 22px rgba(85, 193, 255, .22) !important;
320
+ }
321
+
322
+ #make-rhyme:hover,
323
+ #make-audio:hover {
324
+ transform: translateY(-1px);
325
+ }
326
+
327
+ /* Accordion */
328
+ .gradio-container .accordion {
329
+ background: #132b50 !important;
330
+ color: #f6fbff !important;
331
+ border-color: rgba(170, 201, 242, .18) !important;
332
+ border-radius: 16px !important;
333
+ }
334
+
335
+ .gradio-container .accordion button,
336
+ .gradio-container .accordion span {
337
+ color: #f6fbff !important;
338
+ }
339
+
340
+ /* Examples */
341
+ .gradio-container table {
342
+ background: #10264a !important;
343
+ color: #f5f9ff !important;
344
+ border-color: rgba(170, 201, 242, .18) !important;
345
+ }
346
+
347
+ .gradio-container table th {
348
+ background: #17335f !important;
349
+ color: #ffffff !important;
350
+ border-color: rgba(170, 201, 242, .18) !important;
351
+ }
352
+
353
+ .gradio-container table td {
354
+ background: #122b51 !important;
355
+ color: #edf5ff !important;
356
+ border-color: rgba(170, 201, 242, .13) !important;
357
+ }
358
+
359
+ /* Audio/result area */
360
+ #result-note {
361
+ background: #0c1f3d !important;
362
+ border: 1px solid rgba(118, 188, 246, .24) !important;
363
+ border-radius: 16px;
364
+ padding: 12px 14px;
365
+ color: #d7e7fb !important;
366
+ margin-top: 5px;
367
+ }
368
+
369
+ #result-note p,
370
+ #result-note span {
371
+ color: #d7e7fb !important;
372
+ }
373
+
374
+ .gradio-container audio {
375
+ filter: none !important;
376
+ }
377
+
378
+ #safety-note {
379
+ margin: 20px auto 0;
380
+ max-width: 960px;
381
+ text-align: center;
382
+ color: #9eb1cb !important;
383
+ font-size: 12.5px;
384
+ line-height: 1.55;
385
+ }
386
+
387
+ /* Mobile */
388
+ /* Twinkling stars: two fixed layers behind the app */
389
+ body::before,
390
+ body::after {
391
+ content: "";
392
+ position: fixed;
393
+ inset: 0;
394
+ pointer-events: none;
395
+ z-index: 0;
396
+ }
397
+
398
+ body::before {
399
+ background-image:
400
+ radial-gradient(1.5px 1.5px at 20px 30px, #ffffff, transparent),
401
+ radial-gradient(1px 1px at 90px 120px, #cfe8ff, transparent),
402
+ radial-gradient(2px 2px at 160px 70px, #ffffff, transparent),
403
+ radial-gradient(1px 1px at 230px 180px, #ffe9a8, transparent),
404
+ radial-gradient(1.5px 1.5px at 60px 210px, #ffffff, transparent),
405
+ radial-gradient(1px 1px at 300px 40px, #ffd0e6, transparent);
406
+ background-size: 340px 260px;
407
+ animation: twinkle 4s ease-in-out infinite;
408
+ }
409
+
410
+ body::after {
411
+ background-image:
412
+ radial-gradient(2px 2px at 50px 60px, #ffe9a8, transparent),
413
+ radial-gradient(1.5px 1.5px at 210px 150px, #ffffff, transparent),
414
+ radial-gradient(2.5px 2.5px at 330px 90px, #ffd0e6, transparent),
415
+ radial-gradient(1px 1px at 120px 300px, #cfe8ff, transparent),
416
+ radial-gradient(2px 2px at 400px 260px, #ffffff, transparent);
417
+ background-size: 470px 390px;
418
+ animation: twinkle 6s ease-in-out infinite 2s;
419
+ }
420
+
421
+ @keyframes twinkle {
422
+ 0%, 100% { opacity: .30; }
423
+ 50% { opacity: 1; }
424
+ }
425
+
426
+ .gradio-container {
427
+ position: relative !important;
428
+ z-index: 1;
429
+ }
430
+
431
+ #hero h1 {
432
+ text-shadow: 0 0 22px rgba(255, 215, 94, .45), 0 3px 18px rgba(0, 0, 0, .25);
433
+ }
434
+
435
+ @media (prefers-reduced-motion: reduce) {
436
+ body::before, body::after { animation: none; }
437
+ }
438
+
439
+ @media (max-width: 700px) {
440
+ .gradio-container {
441
+ padding: 18px 12px 28px !important;
442
+ }
443
+
444
+ #hero {
445
+ padding: 68px 18px 28px;
446
+ border-radius: 22px;
447
+ }
448
+
449
+ #hero h1 {
450
+ font-size: 2.25rem;
451
+ }
452
+
453
+ #hero-copyright {
454
+ top: 16px;
455
+ left: 17px;
456
+ font-size: 12px;
457
+ }
458
+
459
+ #hero-badge {
460
+ top: 12px;
461
+ right: 14px;
462
+ font-size: 11px;
463
+ padding: 6px 9px;
464
+ }
465
+
466
+ #steps {
467
+ margin-bottom: 17px;
468
+ }
469
+
470
+ .step-arrow {
471
+ display: none;
472
+ }
473
+
474
+ .studio-card {
475
+ padding: 13px !important;
476
+ border-radius: 19px !important;
477
+ }
478
+
479
+ #lyrics textarea {
480
+ min-height: 250px !important;
481
+ }
482
+ }
483
+ """
484
+
485
+
486
+ def create_rhyme(name, words, goal, language, mood, theme, use_ai):
487
+ try:
488
+ req = parse_request(name, words, goal, language, mood, theme)
489
+ except ValueError as exc:
490
+ raise gr.Error(str(exc)) from exc
491
+ rhyme, writer = write_rhyme(req, use_ai)
492
+ return rhyme, asdict(req), f"✨ {language} rhyme ready · {theme} ({writer}). You can edit it, then sing it.", None
493
+
494
+
495
+ def create_audio(lyrics, settings, name, words, goal, language, mood, theme):
496
+ try:
497
+ if not settings:
498
+ raise ValueError("Write a rhyme first, then make its song.")
499
+ req = parse_request(name, words, goal, language, mood, theme)
500
+ if asdict(req) != settings:
501
+ raise ValueError("Your options changed. Click Make my rhyme again so the lyrics match your language and theme.")
502
+ safe_lyrics = validate_lyric_for_audio(lyrics)
503
+ result, status = make_sung_song(safe_lyrics, req.language, req.mood, req.theme, req.goal)
504
+ return result, f"🎤 {language} · {theme} — {status}"
505
+ except (ValueError, RuntimeError) as exc:
506
+ raise gr.Error(str(exc)) from exc
507
+
508
+
509
+ with gr.Blocks(title="Kids Rhyme Studio") as demo:
510
+ gr.HTML("""
511
+ <section id="hero">
512
+ <div id="hero-copyright">© JDM</div>
513
+ <div id="hero-badge">🌈 Made for little learners</div>
514
+ <h1>🎵 Kids Rhyme Studio</h1>
515
+ <p>Turn a child's favorite words and learning goal into a fun little rhyme — then make it sing.</p>
516
+ </section>
517
+
518
+ <div id="steps" aria-label="How it works">
519
+ <span class="step-pill">✏️ 1. Add words</span>
520
+ <span class="step-arrow">›</span>
521
+ <span class="step-pill">✨ 2. Make a rhyme</span>
522
+ <span class="step-arrow">›</span>
523
+ <span class="step-pill">🎤 3. Sing & download</span>
524
+ </div>
525
+ """)
526
+
527
+ settings = gr.State(value=None)
528
+
529
+ with gr.Row(equal_height=False):
530
+ with gr.Column(scale=1, elem_classes=["studio-card"]):
531
+ gr.HTML("""
532
+ <div class="card-title">🧸 Build the rhyme</div>
533
+ <div class="card-subtitle">Keep it simple: add a name, a few favorite words, then choose a lesson.</div>
534
+ """)
535
+
536
+ name = gr.Textbox(
537
+ label="Child's first name (optional)",
538
+ placeholder="Maya",
539
+ max_length=32,
540
+ )
541
+ words = gr.Textbox(
542
+ label="Words to use (1–10)",
543
+ placeholder="moon, bunny, stars, rainbow…",
544
+ info="Separate up to 10 words with commas. In Telugu, try Telugu words.",
545
+ max_length=300,
546
+ )
547
+
548
+ with gr.Row():
549
+ language = gr.Dropdown(
550
+ ["English", "Español", "తెలుగు", "Deutsch"],
551
+ value="English",
552
+ label="🌎 Language",
553
+ )
554
+ mood = gr.Dropdown(
555
+ ["Bouncy", "Calm"],
556
+ value="Bouncy",
557
+ label="🎶 Music mood",
558
+ )
559
+
560
+ theme = gr.Dropdown(
561
+ THEME_CHOICES,
562
+ value="Good Habits",
563
+ label="🌟 Song theme",
564
+ )
565
+ goal = gr.Textbox(
566
+ label="Theme prompt (optional; required for Custom theme)",
567
+ placeholder="Teach washing hands before meals and putting toys away",
568
+ info="Use the chosen language for your words and prompt. Leave blank to use the theme's suggested lesson.",
569
+ lines=2,
570
+ max_length=160,
571
+ )
572
+
573
+ with gr.Accordion("🤖 Optional: AI writer", open=False):
574
+ use_ai = gr.Checkbox(
575
+ label="Use AI for more varied lyrics",
576
+ info="If enabled, the name, words, theme, and prompt are sent to a hosted model. A Space token must be configured.",
577
+ value=False,
578
+ )
579
+
580
+ rhyme_button = gr.Button(
581
+ "✨ Make my rhyme",
582
+ variant="primary",
583
+ elem_id="make-rhyme",
584
+ )
585
+
586
+ gr.Examples(
587
+ examples=[
588
+ ["Maya", "soap, toothbrush, toys", "", "English", "Bouncy", "Good Habits"],
589
+ ["Maya", "moon, bunny, stars, rainbow, puddle, pencil, apple, rocket, kitten, garden",
590
+ "", "English", "Bouncy", "Animals & Nature"],
591
+ ["Sofía", "luna, conejo, estrellas", "", "Español", "Calm", "Bedtime"],
592
+ ["అను", "చందమామ, బొమ్మ, నక్షత్రం", "", "తెలుగు", "Calm", "Bedtime"],
593
+ ["Emil", "Apfel, Hase, Sterne", "", "Deutsch", "Bouncy", "Counting"],
594
+ ["Maya", "bus, school, friends", "Feeling brave on the first day of school", "English", "Bouncy", "Custom theme"],
595
+ ],
596
+ inputs=[name, words, goal, language, mood, theme],
597
+ label="Try an example",
598
+ )
599
+
600
+ with gr.Column(scale=1, elem_classes=["studio-card"]):
601
+ gr.HTML("""
602
+ <div class="card-title">🎨 Your rhyme</div>
603
+ <div class="card-subtitle">Read it, change any words you like, then turn it into a song.</div>
604
+ """)
605
+
606
+ lyrics = gr.Textbox(
607
+ label="Your rhyme • you can edit it",
608
+ lines=13,
609
+ max_lines=15,
610
+ buttons=["copy"],
611
+ elem_id="lyrics",
612
+ )
613
+ audio_button = gr.Button(
614
+ "🎤 Sing my rhyme",
615
+ elem_id="make-audio",
616
+ )
617
+ audio = gr.Audio(
618
+ label="🎧 Sung song • listen or download WAV",
619
+ interactive=False,
620
+ buttons=["download"],
621
+ )
622
+ status = gr.Markdown(
623
+ "Your rhyme will appear here. Song creation uses a GPU and may take a minute.",
624
+ elem_id="result-note",
625
+ )
626
+
627
+ gr.HTML(
628
+ """
629
+ <div id="safety-note">
630
+ Made for playful practice. A parent should review each rhyme. The song model sings the rhyme;
631
+ pronunciation and exact words can vary. Use a nickname; this app keeps no account or rhyme database.
632
+ </div>
633
+ """
634
+ )
635
+
636
+ rhyme_button.click(
637
+ create_rhyme,
638
+ [name, words, goal, language, mood, theme, use_ai],
639
+ [lyrics, settings, status, audio],
640
+ concurrency_limit=2,
641
+ )
642
+ audio_button.click(
643
+ create_audio,
644
+ [lyrics, settings, name, words, goal, language, mood, theme],
645
+ [audio, status],
646
+ concurrency_limit=1,
647
+ )
648
+
649
+
650
+ if __name__ == "__main__":
651
+ demo.queue().launch(
652
+ theme=THEME,
653
+ css=CSS,
654
+ )