englissi commited on
Commit
9151d1e
Β·
verified Β·
1 Parent(s): 101e043

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
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()