Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -217,158 +217,34 @@ with gr.Blocks(title="π κ·μ¬μ΄ μ€ν 리 μ±") as demo:
|
|
217 |
gr.HTML("<h1>π μ¬λ―Έμλ μμ΄ μ€ν 리 νμ! π</h1>")
|
218 |
gr.HTML("<p>π± κ·μ¬μ΄ μ΄μΌκΈ°μ ν¨κ» μμ΄λ₯Ό λ°°μ보μμ! <br> λ²νΌμ λλ¬ λ€μ μ΄μΌκΈ°λ‘ λμ΄κ°κ³ , μμ±μ λ€μΌλ©° λ°λΌ μ½μ΄λ³΄μΈμ! π΅</p>")
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
with gr.TabItem("Long Vowel (μ₯λͺ¨μ)"):
|
250 |
-
state_index_long = gr.State(value=init_index_long)
|
251 |
-
state_text_long = gr.State(value=init_text_long)
|
252 |
-
|
253 |
-
story_text_long = gr.HTML(value=f"<div class='story-text'>{init_text_long}</div>")
|
254 |
-
story_image_long = gr.Image(value=init_image_long, width=300, height=300)
|
255 |
-
audio_output_long = gr.Audio(value=init_audio_long, autoplay=False)
|
256 |
-
|
257 |
-
with gr.Row():
|
258 |
-
next_button_long = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
259 |
-
play_button_long = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
260 |
-
|
261 |
-
next_button_long.click(
|
262 |
-
fn=next_story,
|
263 |
-
inputs=[state_index_long, gr.State(value=long_vowel_stories)],
|
264 |
-
outputs=[state_index_long, story_text_long, story_image_long, audio_output_long, state_text_long]
|
265 |
-
)
|
266 |
-
|
267 |
-
play_button_long.click(
|
268 |
-
fn=play_story,
|
269 |
-
inputs=[state_text_long],
|
270 |
-
outputs=[audio_output_long]
|
271 |
-
)
|
272 |
-
|
273 |
-
# -- Blends & Digraphs Tab --
|
274 |
-
with gr.TabItem("Blends (μ΄μ€μμ)"):
|
275 |
-
state_index_blends = gr.State(value=init_index_blends)
|
276 |
-
state_text_blends = gr.State(value=init_text_blends)
|
277 |
-
|
278 |
-
story_text_blends = gr.HTML(value=f"<div class='story-text'>{init_text_blends}</div>")
|
279 |
-
story_image_blends = gr.Image(value=init_image_blends, width=300, height=300)
|
280 |
-
audio_output_blends = gr.Audio(value=init_audio_blends, autoplay=False)
|
281 |
-
|
282 |
-
with gr.Row():
|
283 |
-
next_button_blends = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
284 |
-
play_button_blends = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
285 |
-
|
286 |
-
next_button_blends.click(
|
287 |
-
fn=next_story,
|
288 |
-
inputs=[state_index_blends, gr.State(value=blends_digraphs_stories)],
|
289 |
-
outputs=[state_index_blends, story_text_blends, story_image_blends, audio_output_blends, state_text_blends]
|
290 |
-
)
|
291 |
-
|
292 |
-
play_button_blends.click(
|
293 |
-
fn=play_story,
|
294 |
-
inputs=[state_text_blends],
|
295 |
-
outputs=[audio_output_blends]
|
296 |
-
)
|
297 |
-
|
298 |
-
# -- The Red Ball Tab --
|
299 |
-
with gr.TabItem("The Red Ball"):
|
300 |
-
state_index_red_ball = gr.State(value=the_red_ball_index)
|
301 |
-
state_text_red_ball = gr.State(value=the_red_ball_text)
|
302 |
-
|
303 |
-
story_text_red_ball = gr.HTML(value=f"<div class='story-text'>{the_red_ball_text}</div>")
|
304 |
-
story_image_red_ball = gr.Image(value=the_red_ball_image, width=300, height=300)
|
305 |
-
audio_output_red_ball = gr.Audio(value=the_red_ball_audio, autoplay=False)
|
306 |
-
|
307 |
-
with gr.Row():
|
308 |
-
next_button_red_ball = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
309 |
-
play_button_red_ball = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
310 |
-
|
311 |
-
next_button_red_ball.click(
|
312 |
-
fn=next_story,
|
313 |
-
inputs=[state_index_red_ball, gr.State(value=the_red_ball_story)],
|
314 |
-
outputs=[state_index_red_ball, story_text_red_ball, story_image_red_ball, audio_output_red_ball, state_text_red_ball]
|
315 |
-
)
|
316 |
-
|
317 |
-
play_button_red_ball.click(
|
318 |
-
fn=play_story,
|
319 |
-
inputs=[state_text_red_ball],
|
320 |
-
outputs=[audio_output_red_ball]
|
321 |
-
)
|
322 |
-
|
323 |
-
# -- The Big Cat Tab --
|
324 |
-
with gr.TabItem("The Big Cat"):
|
325 |
-
state_index_big_cat = gr.State(value=the_big_cat_index)
|
326 |
-
state_text_big_cat = gr.State(value=the_big_cat_text)
|
327 |
-
|
328 |
-
story_text_big_cat = gr.HTML(value=f"<div class='story-text'>{the_big_cat_text}</div>")
|
329 |
-
story_image_big_cat = gr.Image(value=the_big_cat_image, width=300, height=300)
|
330 |
-
audio_output_big_cat = gr.Audio(value=the_big_cat_audio, autoplay=False)
|
331 |
-
|
332 |
-
with gr.Row():
|
333 |
-
next_button_big_cat = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
334 |
-
play_button_big_cat = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
335 |
-
|
336 |
-
next_button_big_cat.click(
|
337 |
-
fn=next_story,
|
338 |
-
inputs=[state_index_big_cat, gr.State(value=the_big_cat_story)],
|
339 |
-
outputs=[state_index_big_cat, story_text_big_cat, story_image_big_cat, audio_output_big_cat, state_text_big_cat]
|
340 |
-
)
|
341 |
-
|
342 |
-
play_button_big_cat.click(
|
343 |
-
fn=play_story,
|
344 |
-
inputs=[state_text_big_cat],
|
345 |
-
outputs=[audio_output_big_cat]
|
346 |
-
)
|
347 |
-
|
348 |
-
# -- The Hot Sun --
|
349 |
-
with gr.TabItem("The Hot Sun"):
|
350 |
-
state_index_hot_sun = gr.State(value=the_hot_sun_index)
|
351 |
-
state_text_hot_sun = gr.State(value=the_hot_sun_text)
|
352 |
-
|
353 |
-
story_text_hot_sun = gr.HTML(value=f"<div class='story-text'>{the_hot_sun_text}</div>")
|
354 |
-
story_image_hot_sun = gr.Image(value=the_hot_sun_image, width=300, height=300)
|
355 |
-
audio_output_hot_sun = gr.Audio(value=the_hot_sun_audio, autoplay=False)
|
356 |
-
|
357 |
-
with gr.Row():
|
358 |
-
next_button_hot_sun = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
359 |
-
play_button_hot_sun = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
360 |
-
|
361 |
-
next_button_hot_sun.click(
|
362 |
-
fn=next_story,
|
363 |
-
inputs=[state_index_hot_sun, gr.State(value=the_hot_sun_story)],
|
364 |
-
outputs=[state_index_hot_sun, story_text_hot_sun, story_image_hot_sun, audio_output_hot_sun, state_text_hot_sun]
|
365 |
-
)
|
366 |
-
|
367 |
-
play_button_hot_sun.click(
|
368 |
-
fn=play_story,
|
369 |
-
inputs=[state_text_hot_sun],
|
370 |
-
outputs=[audio_output_hot_sun]
|
371 |
-
)
|
372 |
-
|
373 |
# π μ± μ€ν
|
374 |
demo.launch()
|
|
|
217 |
gr.HTML("<h1>π μ¬λ―Έμλ μμ΄ μ€ν 리 νμ! π</h1>")
|
218 |
gr.HTML("<p>π± κ·μ¬μ΄ μ΄μΌκΈ°μ ν¨κ» μμ΄λ₯Ό λ°°μ보μμ! <br> λ²νΌμ λλ¬ λ€μ μ΄μΌκΈ°λ‘ λμ΄κ°κ³ , μμ±μ λ€μΌλ©° λ°λΌ μ½μ΄λ³΄μΈμ! π΅</p>")
|
219 |
|
220 |
+
with gr.Tabs():
|
221 |
+
for story_name, story_data in [("Short Vowel", short_vowel_stories),
|
222 |
+
("Long Vowel", long_vowel_stories),
|
223 |
+
("Blends & Digraphs", blends_digraphs_stories),
|
224 |
+
("The Red Ball", the_red_ball_story),
|
225 |
+
("The Big Cat", the_big_cat_story),
|
226 |
+
("The Hot Sun", the_hot_sun_story)]:
|
227 |
+
with gr.TabItem(story_name):
|
228 |
+
state_index = gr.State(value=0)
|
229 |
+
state_text = gr.State(value=story_data[0]["text"])
|
230 |
+
|
231 |
+
story_text = gr.HTML(value=f"<div class='story-text'>{story_data[0]['text']}</div>")
|
232 |
+
story_image = gr.Image(value=story_data[0]["image"], width=300, height=300)
|
233 |
+
audio_output = gr.Audio(value=generate_audio(story_data[0]["text"]), autoplay=False)
|
234 |
+
|
235 |
+
with gr.Row():
|
236 |
+
next_button = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
237 |
+
play_button = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
238 |
+
|
239 |
+
next_button.click(
|
240 |
+
fn=next_story,
|
241 |
+
inputs=[state_index, gr.State(value=story_data)],
|
242 |
+
outputs=[state_index, story_text, story_image, audio_output, state_text]
|
243 |
+
)
|
244 |
+
play_button.click(
|
245 |
+
fn=play_story,
|
246 |
+
inputs=[state_text],
|
247 |
+
outputs=[audio_output]
|
248 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
# π μ± μ€ν
|
250 |
demo.launch()
|