Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 193 |
# -------------------------------------------------------------
|
| 194 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
| 195 |
|
| 196 |
-
# Inject CSS manually
|
| 197 |
gr.HTML(f"<style>{custom_css}</style>")
|
| 198 |
|
| 199 |
-
gr.HTML(""
|
| 200 |
-
<div class="
|
| 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 |
-
|
| 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
|
| 269 |
-
|
|
|
|
|
|
|
| 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()
|