Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -34,6 +34,27 @@ long_vowel_stories = [ | |
| 34 | 
             
                {"text": "A baby bird flew away.", "image": f"{image_base_url}20.webp"}
         | 
| 35 | 
             
            ]
         | 
| 36 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 37 | 
             
            # π gTTSλ₯Ό μ¬μ©νμ¬ μμ± νμΌ μμ± (κ³ μ ν νμΌλͺ
 + μΊμ± μμ€ν
 μΆκ°)
         | 
| 38 | 
             
            cached_audio = {}  # κ°μ λ¬Έμ₯μ λν΄ APIλ₯Ό μ¬λ¬ λ² νΈμΆνμ§ μλλ‘ μ μ₯
         | 
| 39 |  | 
| @@ -80,6 +101,8 @@ def play_story(current_text): | |
| 80 | 
             
            # π μ΄κΈ° λ°μ΄ν° μ€μ 
         | 
| 81 | 
             
            init_index_short, init_text_short, init_image_short, init_audio_short = 0, short_vowel_stories[0]["text"], short_vowel_stories[0]["image"], generate_audio(short_vowel_stories[0]["text"])
         | 
| 82 | 
             
            init_index_long, init_text_long, init_image_long, init_audio_long = 0, long_vowel_stories[0]["text"], long_vowel_stories[0]["image"], generate_audio(long_vowel_stories[0]["text"])
         | 
|  | |
|  | |
| 83 |  | 
| 84 | 
             
            # π Gradio UI ꡬμ±
         | 
| 85 | 
             
            with gr.Blocks(title="π κ·μ¬μ΄ μ€ν λ¦¬ μ±") as demo:
         | 
| @@ -199,5 +222,27 @@ with gr.Blocks(title="π κ·μ¬μ΄ μ€ν λ¦¬ μ±") as demo: | |
| 199 | 
             
                            outputs=[audio_output_long]
         | 
| 200 | 
             
                        )
         | 
| 201 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 202 | 
             
            # π μ± μ€ν
         | 
| 203 | 
             
            demo.launch()
         | 
|  | |
| 34 | 
             
                {"text": "A baby bird flew away.", "image": f"{image_base_url}20.webp"}
         | 
| 35 | 
             
            ]
         | 
| 36 |  | 
| 37 | 
            +
            # π Blends & Digraphs μ€ν λ¦¬ λ°μ΄ν°
         | 
| 38 | 
            +
            blends_digraphs_stories = [
         | 
| 39 | 
            +
                {"text": "Blake blows a blue blimp.", "image": f"{image_base_url}21.webp"},
         | 
| 40 | 
            +
                {"text": "Brad brings a brown brush.", "image": f"{image_base_url}22.webp"},
         | 
| 41 | 
            +
                {"text": "The clock clicks and claps.", "image": f"{image_base_url}23.webp"},
         | 
| 42 | 
            +
                {"text": "Crispy crackers crunch.", "image": f"{image_base_url}24.webp"},
         | 
| 43 | 
            +
                {"text": "A frog frogs on a free log.", "image": f"{image_base_url}25.webp"},
         | 
| 44 | 
            +
                {"text": "Green grapes grow big.", "image": f"{image_base_url}26.webp"},
         | 
| 45 | 
            +
                {"text": "The train trips on tracks.", "image": f"{image_base_url}27.webp"},
         | 
| 46 | 
            +
                {"text": "The ship shines in the sun.", "image": f"{image_base_url}28.webp"},
         | 
| 47 | 
            +
                {"text": "Chip and cheese are on my chin.", "image": f"{image_base_url}29.webp"},
         | 
| 48 | 
            +
                {"text": "The thumb is thick.", "image": f"{image_base_url}30.webp"},
         | 
| 49 | 
            +
                {"text": "White whales whisper.", "image": f"{image_base_url}31.webp"},
         | 
| 50 | 
            +
                {"text": "A skunk skips sky-high.", "image": f"{image_base_url}32.webp"},
         | 
| 51 | 
            +
                {"text": "The sleepy sloth slides.", "image": f"{image_base_url}33.webp"},
         | 
| 52 | 
            +
                {"text": "Small smiles smell sweet.", "image": f"{image_base_url}34.webp"},
         | 
| 53 | 
            +
                {"text": "The snail snaps a snack.", "image": f"{image_base_url}35.webp"},
         | 
| 54 | 
            +
                {"text": "The spider spins a spotty web.", "image": f"{image_base_url}36.webp"},
         | 
| 55 | 
            +
                {"text": "The star stands in the storm.", "image": f"{image_base_url}37.webp"},
         | 
| 56 | 
            +
                {"text": "A swan swims in the sweet lake.", "image": f"{image_base_url}38.webp"}
         | 
| 57 | 
            +
             | 
| 58 | 
             
            # π gTTSλ₯Ό μ¬μ©νμ¬ μμ± νμΌ μμ± (κ³ μ ν νμΌλͺ
 + μΊμ± μμ€ν
 μΆκ°)
         | 
| 59 | 
             
            cached_audio = {}  # κ°μ λ¬Έμ₯μ λν΄ APIλ₯Ό μ¬λ¬ λ² νΈμΆνμ§ μλλ‘ μ μ₯
         | 
| 60 |  | 
|  | |
| 101 | 
             
            # π μ΄κΈ° λ°μ΄ν° μ€μ 
         | 
| 102 | 
             
            init_index_short, init_text_short, init_image_short, init_audio_short = 0, short_vowel_stories[0]["text"], short_vowel_stories[0]["image"], generate_audio(short_vowel_stories[0]["text"])
         | 
| 103 | 
             
            init_index_long, init_text_long, init_image_long, init_audio_long = 0, long_vowel_stories[0]["text"], long_vowel_stories[0]["image"], generate_audio(long_vowel_stories[0]["text"])
         | 
| 104 | 
            +
            init_index_blends, init_text_blends, init_image_blends, init_audio_blends = 0, blends_digraphs_stories[0]["text"], blends_digraphs_stories[0]["image"], generate_audio(blends_digraphs_stories[0]["text"])
         | 
| 105 | 
            +
             | 
| 106 |  | 
| 107 | 
             
            # π Gradio UI ꡬμ±
         | 
| 108 | 
             
            with gr.Blocks(title="π κ·μ¬μ΄ μ€ν λ¦¬ μ±") as demo:
         | 
|  | |
| 222 | 
             
                            outputs=[audio_output_long]
         | 
| 223 | 
             
                        )
         | 
| 224 |  | 
| 225 | 
            +
                    with gr.TabItem("Blends (μ΄μ€μμ)"):
         | 
| 226 | 
            +
                        state_index_blends = gr.State(value=init_index_blends)
         | 
| 227 | 
            +
                        state_text_blends = gr.State(value=init_text_blends)
         | 
| 228 | 
            +
             | 
| 229 | 
            +
                        story_text_blends = gr.HTML(value=f"<div class='story-text'>{init_text_blends}</div>")
         | 
| 230 | 
            +
                        story_image_blends = gr.Image(value=init_image_blends, width=300, height=300)
         | 
| 231 | 
            +
                        audio_output_blends = gr.Audio(value=init_audio_blends, autoplay=False)
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                        with gr.Row():
         | 
| 234 | 
            +
                            next_button_blends = gr.Button("π λ€μ μ΄μΌκΈ°", elem_classes=["btn-custom", "next-btn"])
         | 
| 235 | 
            +
                            play_button_blends = gr.Button("π λ€μ λ£κΈ°", elem_classes=["btn-custom", "play-btn"])
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                        next_button_long.click(
         | 
| 238 | 
            +
                            fn=next_story,
         | 
| 239 | 
            +
                            inputs=[state_index_blends, gr.State(value=blends_digraphs_storiesies)],
         | 
| 240 | 
            +
                            outputs=[state_index_blends, story_text_blends, story_image_blends, audio_output_blends, state_text_blends]
         | 
| 241 | 
            +
                        )
         | 
| 242 | 
            +
             | 
| 243 | 
            +
                        play_button_blends.click(
         | 
| 244 | 
            +
                            fn=play_story,
         | 
| 245 | 
            +
                            inputs=[state_text_blends],
         | 
| 246 | 
            +
                            outputs=[audio_output_blends]
         | 
| 247 | 
             
            # π μ± μ€ν
         | 
| 248 | 
             
            demo.launch()
         | 
