|
import gradio as gr |
|
|
|
def show_prayer_and_music(prayer_selection, music_selection): |
|
prayers = { |
|
"보νμ κΈ°λ": "μ£Όλμ 보νλ‘ λλ₯Ό μ»μ΄μ£Όμκ³ , 보νΈν΄μ£Όμμ.", |
|
"μλ
λ₯Ό μν κΈ°λ": "μ¬λνλ μλ
λ€μ΄ μ£Όλμ μΆλ³΅ μμμ μλΌλκ² νμμ.", |
|
"μΉμ κΈ°λ": "μ£Όλμ μκΈΈλ‘ λ΄ λͺΈκ³Ό λ§μμ μΉμ ν΄μ£Όμμ." |
|
} |
|
|
|
music_urls = { |
|
"μμ
1": "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3", |
|
"μμ
2": "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3", |
|
"μμ
3": "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3" |
|
} |
|
|
|
prayer_text = prayers.get(prayer_selection, "μ νλ κΈ°λκ° μμ΅λλ€.") |
|
music_url = music_urls.get(music_selection, "") |
|
|
|
html_code = f""" |
|
<audio id="background-music" controls autoplay loop> |
|
<source src="{music_url}" type="audio/mpeg"> |
|
Your browser does not support the audio element. |
|
</audio> |
|
<style> |
|
body {{ |
|
background-color: #f5f5dc; /* μ°ν λ² μ΄μ§μ */ |
|
}} |
|
</style> |
|
""" |
|
|
|
return prayer_text, html_code |
|
|
|
prayer_options = ["보νμ κΈ°λ", "μλ
λ₯Ό μν κΈ°λ", "μΉμ κΈ°λ"] |
|
music_options = ["μμ
1", "μμ
2", "μμ
3"] |
|
|
|
prayer_dropdown = gr.Dropdown(choices=prayer_options, label="κΈ°λλ¬Έ μ ν") |
|
music_dropdown = gr.Dropdown(choices=music_options, label="λ°°κ²½μμ
μ ν") |
|
output_text = gr.Textbox(label="κΈ°λλ¬Έ") |
|
output_html = gr.HTML(label="λ°°κ²½μμ
") |
|
|
|
interface = gr.Interface( |
|
fn=show_prayer_and_music, |
|
inputs=[prayer_dropdown, music_dropdown], |
|
outputs=[output_text, output_html], |
|
live=True |
|
) |
|
|
|
interface.launch() |
|
|