Ansa12 commited on
Commit
3ad1d16
Β·
verified Β·
1 Parent(s): b3dd657

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -33
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import os
3
  from groq import Groq
4
  import gradio as gr
@@ -7,7 +6,6 @@ import re
7
 
8
  # Get API key from Hugging Face Secrets
9
  groq_key = os.environ.get("Groq_API_Key")
10
-
11
  if not groq_key:
12
  raise ValueError("Groq_API_Key not found in environment variables. Please add it to your Hugging Face Space secrets.")
13
 
@@ -104,7 +102,6 @@ theme_options = [
104
  ]
105
  language_options = ["English", "Urdu"]
106
 
107
-
108
  # -------------------------------------------------------------
109
  # CUSTOM CSS
110
  # -------------------------------------------------------------
@@ -187,26 +184,16 @@ custom_css = """
187
  }
188
  """
189
 
190
-
191
  # -------------------------------------------------------------
192
- # BUILD GRADIO INTERFACE (Correct for Gradio 4.x)
193
  # -------------------------------------------------------------
194
  with gr.Blocks(theme=gr.themes.Soft()) as iface:
195
 
196
- # Inject CSS manually (Gradio 4.x)
197
  gr.HTML(f"<style>{custom_css}</style>")
198
 
199
- gr.HTML("""
200
- <div class="main-header">
201
- 🌈 StoryTime AIπŸŽͺ
202
- </div>
203
- """)
204
-
205
- gr.HTML("""
206
- <div class="subtitle">
207
- 🎯 Create amazing stories that spark imagination and teach valuable lessons!
208
- </div>
209
- """)
210
 
211
  with gr.Row():
212
  # LEFT PANEL
@@ -235,25 +222,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
235
  # RIGHT PANEL
236
  with gr.Column(scale=2):
237
  with gr.Group(elem_classes="story-container"):
238
- gr.Markdown("### πŸ“– Your Magical Story")
239
  story_output = gr.Markdown(
240
  "Your story will appear here! Choose settings and click the magic button! πŸŽ‡",
241
  show_label=False
242
  )
243
 
244
- with gr.Group():
245
- gr.Markdown("### 🎧 Listen to Your Story")
246
- audio_output = gr.Audio(
247
- label="Audio Story",
248
- elem_classes="audio-player",
249
- show_label=False
250
- )
251
 
252
- gr.HTML("""
253
- <div class="footer">
254
- Made with ❀ for young readers everywhere! | Watch your stories come to life! ✨
255
- </div>
256
- """)
257
 
258
  generate_btn.click(
259
  create_story_interface,
@@ -261,9 +237,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
261
  [story_output, audio_output]
262
  )
263
 
264
-
265
  # -------------------------------------------------------------
266
  # LAUNCH APP
267
  # -------------------------------------------------------------
268
- if _name_ == "_main_":
269
- Β Β iface.launch()
 
 
1
  import os
2
  from groq import Groq
3
  import gradio as gr
 
6
 
7
  # Get API key from Hugging Face Secrets
8
  groq_key = os.environ.get("Groq_API_Key")
 
9
  if not groq_key:
10
  raise ValueError("Groq_API_Key not found in environment variables. Please add it to your Hugging Face Space secrets.")
11
 
 
102
  ]
103
  language_options = ["English", "Urdu"]
104
 
 
105
  # -------------------------------------------------------------
106
  # CUSTOM CSS
107
  # -------------------------------------------------------------
 
184
  }
185
  """
186
 
 
187
  # -------------------------------------------------------------
188
+ # BUILD GRADIO INTERFACE
189
  # -------------------------------------------------------------
190
  with gr.Blocks(theme=gr.themes.Soft()) as iface:
191
 
192
+ # Inject CSS manually
193
  gr.HTML(f"<style>{custom_css}</style>")
194
 
195
+ gr.HTML('<div class="main-header">🌈 StoryTime AIπŸŽͺ</div>')
196
+ gr.HTML('<div class="subtitle">🎯 Create amazing stories that spark imagination and teach valuable lessons!</div>')
 
 
 
 
 
 
 
 
 
197
 
198
  with gr.Row():
199
  # LEFT PANEL
 
222
  # RIGHT PANEL
223
  with gr.Column(scale=2):
224
  with gr.Group(elem_classes="story-container"):
 
225
  story_output = gr.Markdown(
226
  "Your story will appear here! Choose settings and click the magic button! πŸŽ‡",
227
  show_label=False
228
  )
229
 
230
+ audio_output = gr.Audio(label="Audio Story", elem_classes="audio-player", show_label=False)
 
 
 
 
 
 
231
 
232
+ gr.HTML('<div class="footer">Made with ❀ for young readers everywhere! | Watch your stories come to life! ✨</div>')
 
 
 
 
233
 
234
  generate_btn.click(
235
  create_story_interface,
 
237
  [story_output, audio_output]
238
  )
239
 
 
240
  # -------------------------------------------------------------
241
  # LAUNCH APP
242
  # -------------------------------------------------------------
243
+ if __name__ == "__main__":
244
+ iface.launch()