Ansa12 commited on
Commit
efda241
·
verified ·
1 Parent(s): 75db4f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +120 -97
app.py CHANGED
@@ -97,100 +97,105 @@ theme_options = [
97
 
98
  language_options = ["English", "Urdu"]
99
 
100
- # Custom CSS for child-friendly interface
101
- custom_css = """
102
- @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');
103
-
104
- .gradio-container {
105
- font-family: 'Comic Neue', cursive !important;
106
- background: linear-gradient(135deg, #ffafbd, #ffc3a0) !important;
107
- padding: 20px !important;
108
- }
109
-
110
- .main-header {
111
- text-align: center;
112
- font-weight: bold !important;
113
- font-size: 3.2em !important;
114
- margin: 20px 0 !important;
115
- text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
116
- color: #12979B;
117
- }
118
-
119
- .story-container {
120
- background: #fff5ee !important;
121
- border-radius: 20px !important;
122
- padding: 25px !important;
123
- border: 5px solid #FFD166 !important;
124
- box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
125
- min-height: 400px !important;
126
- margin: 20px 0 !important;
127
- }
128
-
129
- .control-panel {
130
- background: #fff5ee !important;
131
- border-radius: 15px !important;
132
- padding: 20px !important;
133
- border: 3px dashed #4ECDC4 !important;
134
- margin: 20px 0 !important;
135
- }
136
-
137
- .generate-btn {
138
- background: linear-gradient(45deg, #FF6B6B, #FF9E7D) !important;
139
- border: none !important;
140
- border-radius: 50px !important;
141
- padding: 15px 30px !important;
142
- font-size: 1.2em !important;
143
- font-weight: bold !important;
144
- color: white !important;
145
- margin: 20px 0 !important;
146
- width: 100% !important;
147
- }
148
-
149
- .generate-btn:hover {
150
- transform: scale(1.05) !important;
151
- box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4) !important;
152
- }
153
-
154
- .dropdown, .checkbox {
155
- background: white !important;
156
- border-radius: 10px !important;
157
- border: 2px solid #96CEB4 !important;
158
- margin: 10px 0 !important;
159
- }
160
-
161
- .audio-player {
162
- border-radius: 15px !important;
163
- margin: 20px 0 !important;
164
- }
165
-
166
- .subtitle {
167
- text-align: center !important;
168
- font-size: 1.5em !important;
169
- font-weight: 600 !important;
170
- color: white !important;
171
- margin: 20px 0 !important;
172
- text-shadow: 1px 1px 2px rgba(0,0,0,0.1) !important;
173
- }
174
-
175
- .footer {
176
- text-align: center !important;
177
- margin: 20px 0 !important;
178
- color: #666 !important;
179
- font-style: italic !important;
180
- font-size: 1.1em !important;
181
- }
182
-
183
- .warning-box {
184
- background: #fff3cd !important;
185
- border: 2px solid #ffeaa7 !important;
186
- border-radius: 10px !important;
187
- padding: 15px !important;
188
- margin: 20px 0 !important;
189
- }
190
- """
191
-
192
- # Create the interface with CSS
193
- with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
 
 
 
 
 
194
 
195
  # Header
196
  gr.HTML("""
@@ -252,11 +257,11 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
252
  info="Generate audio narration"
253
  )
254
 
 
 
255
  generate_btn = gr.Button(
256
- "✨ Create Magical Story! ✨",
257
- elem_classes="generate-btn"
258
  )
259
- gr.HTML('</div>')
260
 
261
  # Right Column - Output
262
  with gr.Column(scale=2):
@@ -282,6 +287,24 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
282
  </div>
283
  """)
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  generate_btn.click(
286
  create_story_interface,
287
  inputs=[age_input, theme_input, language_input, tts_input],
 
97
 
98
  language_options = ["English", "Urdu"]
99
 
100
+ # Create the interface - WITHOUT css parameter
101
+ with gr.Blocks() as iface:
102
+
103
+ # Inject CSS as HTML
104
+ gr.HTML("""
105
+ <style>
106
+ @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');
107
+
108
+ .gradio-container {
109
+ font-family: 'Comic Neue', cursive !important;
110
+ background: linear-gradient(135deg, #ffafbd, #ffc3a0) !important;
111
+ padding: 20px;
112
+ min-height: 100vh;
113
+ }
114
+
115
+ .main-header {
116
+ text-align: center;
117
+ font-weight: bold;
118
+ font-size: 3.2em;
119
+ margin: 20px 0;
120
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
121
+ color: #12979B;
122
+ }
123
+
124
+ .subtitle {
125
+ text-align: center;
126
+ font-size: 1.5em;
127
+ font-weight: 600;
128
+ color: white;
129
+ margin: 20px 0;
130
+ text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
131
+ }
132
+
133
+ .control-panel {
134
+ background: #fff5ee;
135
+ border-radius: 15px;
136
+ padding: 20px;
137
+ border: 3px dashed #4ECDC4;
138
+ margin: 20px 0;
139
+ }
140
+
141
+ .story-container {
142
+ background: #fff5ee;
143
+ border-radius: 20px;
144
+ padding: 25px;
145
+ border: 5px solid #FFD166;
146
+ box-shadow: 0 8px 25px rgba(0,0,0,0.1);
147
+ min-height: 400px;
148
+ margin: 20px 0;
149
+ }
150
+
151
+ .generate-btn {
152
+ background: linear-gradient(45deg, #FF6B6B, #FF9E7D) !important;
153
+ border: none !important;
154
+ border-radius: 50px !important;
155
+ padding: 15px 30px !important;
156
+ font-size: 1.2em !important;
157
+ font-weight: bold !important;
158
+ color: white !important;
159
+ margin: 20px 0 !important;
160
+ width: 100% !important;
161
+ cursor: pointer !important;
162
+ }
163
+
164
+ .generate-btn:hover {
165
+ transform: scale(1.05) !important;
166
+ box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4) !important;
167
+ }
168
+
169
+ .footer {
170
+ text-align: center;
171
+ margin: 20px 0;
172
+ color: #666;
173
+ font-style: italic;
174
+ font-size: 1.1em;
175
+ }
176
+
177
+ .warning-box {
178
+ background: #fff3cd;
179
+ border: 2px solid #ffeaa7;
180
+ border-radius: 10px;
181
+ padding: 15px;
182
+ margin: 20px 0;
183
+ }
184
+
185
+ /* Style Gradio components */
186
+ .gradio-container .dropdown, .gradio-container .checkbox {
187
+ background: white !important;
188
+ border-radius: 10px !important;
189
+ border: 2px solid #96CEB4 !important;
190
+ margin: 10px 0 !important;
191
+ }
192
+
193
+ .gradio-container .audio {
194
+ border-radius: 15px !important;
195
+ margin: 20px 0 !important;
196
+ }
197
+ </style>
198
+ """)
199
 
200
  # Header
201
  gr.HTML("""
 
257
  info="Generate audio narration"
258
  )
259
 
260
+ gr.HTML('</div>')
261
+
262
  generate_btn = gr.Button(
263
+ "✨ Create Magical Story! ✨"
 
264
  )
 
265
 
266
  # Right Column - Output
267
  with gr.Column(scale=2):
 
287
  </div>
288
  """)
289
 
290
+ # Apply button styling with JavaScript
291
+ gr.HTML("""
292
+ <script>
293
+ function styleButton() {
294
+ const buttons = document.querySelectorAll('button');
295
+ buttons.forEach(button => {
296
+ if (button.textContent.includes('Create Magical Story')) {
297
+ button.classList.add('generate-btn');
298
+ }
299
+ });
300
+ }
301
+ // Style button on load and when DOM changes
302
+ document.addEventListener('DOMContentLoaded', styleButton);
303
+ setTimeout(styleButton, 1000);
304
+ setInterval(styleButton, 2000);
305
+ </script>
306
+ """)
307
+
308
  generate_btn.click(
309
  create_story_interface,
310
  inputs=[age_input, theme_input, language_input, tts_input],