Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def generate_song(text, ambiance): | |
| return f"Tu as choisi l'ambiance {ambiance} avec le texte : « {text} »", "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" | |
| ambiences = ["Lofi", "Rap", "Triste", "Épique", "Afro", "Piano"] | |
| custom_css = """ | |
| body { | |
| background-size: cover; | |
| font-family: 'Poppins', sans-serif; | |
| color: #F4F4F4; | |
| } | |
| h1 { | |
| font-size: 3rem; | |
| text-align: center; | |
| color: white; | |
| margin-bottom: 0.5em; | |
| } | |
| button { | |
| background: linear-gradient(90deg, #D946EF, #6366F1); | |
| color: white !important; | |
| border-radius: 8px; | |
| padding: 10px 20px; | |
| font-weight: bold; | |
| } | |
| button:hover { | |
| filter: brightness(1.1); | |
| transform: scale(1.02); | |
| transition: all 0.2s ease-in-out; | |
| } | |
| .radio-item input:checked + label { | |
| background: #5D3FD3; | |
| color: white; | |
| border: none; | |
| } | |
| """ | |
| with gr.Blocks(css=custom_css) as demo: | |
| gr.Markdown(""" | |
| <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet"> | |
| <h1>Tape tes mots.<br>Écoute ta musique.</h1> | |
| """) | |
| with gr.Row(): | |
| text_input = gr.Textbox(placeholder="Raconte-moi une histoire...", lines=4, label="", scale=2) | |
| ambiance = gr.Radio(ambiences, label="", value="Lofi", interactive=True) | |
| generate_btn = gr.Button("🎵 Générer ma chanson") | |
| with gr.Column(): | |
| output_text = gr.Textbox(label="Texte analysé", interactive=False) | |
| audio_output = gr.Audio(label="🎧 Ta chanson", autoplay=True) | |
| with gr.Row(): | |
| gr.Button("Télécharger", interactive=False) | |
| gr.Button("Partager", interactive=False) | |
| generate_btn.click(fn=generate_song, inputs=[text_input, ambiance], outputs=[output_text, audio_output]) | |
| demo.launch() | |