Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -64,6 +64,11 @@ the_red_ball_story = [
|
|
64 |
{"text": "Tom has a red ball. He throws the ball up. The ball goes high. Then it falls down!", "image": f"{image_base_url}39.webp"}
|
65 |
]
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
# π gTTSλ₯Ό μ΄μ©ν΄ μ€λμ€ νμΌμ μμ±νκ±°λ, μ΄λ―Έ μμΌλ©΄ μ¬μ¬μ©
|
68 |
def generate_audio(text):
|
69 |
try:
|
@@ -128,6 +133,10 @@ the_red_ball_text = the_red_ball_story[0]["text"]
|
|
128 |
the_red_ball_image = the_red_ball_story[0]["image"]
|
129 |
the_red_ball_audio = generate_audio(the_red_ball_text)
|
130 |
|
|
|
|
|
|
|
|
|
131 |
|
132 |
# π Gradio UI ꡬμ±
|
133 |
with gr.Blocks(title="π κ·μ¬μ΄ μ€ν 리 μ±") as demo:
|
@@ -301,5 +310,32 @@ with gr.Blocks(title="π κ·μ¬μ΄ μ€ν 리 μ±") as demo:
|
|
301 |
outputs=[audio_output_red_ball]
|
302 |
)
|
303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
# π μ± μ€ν
|
305 |
demo.launch()
|
|
|
64 |
{"text": "Tom has a red ball. He throws the ball up. The ball goes high. Then it falls down!", "image": f"{image_base_url}39.webp"}
|
65 |
]
|
66 |
|
67 |
+
# π "The Big Cat" μ€ν 리 λ°μ΄ν°
|
68 |
+
the_big_cat_story = [
|
69 |
+
{"text": "The cat is big. It jumps on the mat. The mat is soft. The cat takes a nap.", "image": f"{image_base_url}40.webp"}
|
70 |
+
]
|
71 |
+
|
72 |
# π gTTSλ₯Ό μ΄μ©ν΄ μ€λμ€ νμΌμ μμ±νκ±°λ, μ΄λ―Έ μμΌλ©΄ μ¬μ¬μ©
|
73 |
def generate_audio(text):
|
74 |
try:
|
|
|
133 |
the_red_ball_image = the_red_ball_story[0]["image"]
|
134 |
the_red_ball_audio = generate_audio(the_red_ball_text)
|
135 |
|
136 |
+
the_big_cat_index = 0
|
137 |
+
the_big_cat_text = the_big_cat_story[0]["text"]
|
138 |
+
the_big_cat_image = the_big_cat_story[0]["image"]
|
139 |
+
the_big_cat_audio = generate_audio(the_big_cat_text)
|
140 |
|
141 |
# π Gradio UI ꡬμ±
|
142 |
with gr.Blocks(title="π κ·μ¬μ΄ μ€ν 리 μ±") as demo:
|
|
|
310 |
outputs=[audio_output_red_ball]
|
311 |
)
|
312 |
|
313 |
+
# -- The Big Cat Tab --
|
314 |
+
with gr.TabItem("The Big Cat"):
|
315 |
+
with gr.Row():
|
316 |
+
state_index_big_cat = gr.State(value=the_big_cat_index)
|
317 |
+
state_text_big_cat = gr.State(value=the_big_cat_text)
|
318 |
+
|
319 |
+
story_text_big_cat = gr.HTML(value=f"<div class='story-text'>{the_big_cat_text}</div>")
|
320 |
+
story_image_big_cat = gr.Image(value=the_big_cat_image, width=300, height=300)
|
321 |
+
audio_output_big_cat = gr.Audio(value=the_big_cat_audio, autoplay=False)
|
322 |
+
|
323 |
+
with gr.Row():
|
324 |
+
next_button_big_cat = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
|
325 |
+
play_button_big_cat = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
|
326 |
+
|
327 |
+
next_button_big_cat.click(
|
328 |
+
fn=next_story,
|
329 |
+
inputs=[state_index_big_cat, gr.State(value=the_big_cat_story)],
|
330 |
+
outputs=[state_index_big_cat, story_text_big_cat, story_image_big_cat, audio_output_big_cat, state_text_big_cat]
|
331 |
+
)
|
332 |
+
|
333 |
+
play_button_big_cat.click(
|
334 |
+
fn=play_story,
|
335 |
+
inputs=[state_text_big_cat],
|
336 |
+
outputs=[audio_output_big_cat]
|
337 |
+
)
|
338 |
+
|
339 |
+
|
340 |
# π μ± μ€ν
|
341 |
demo.launch()
|