app / app.py
michaelpiro1's picture
Update app.py
364b18e verified
raw
history blame
3.4 kB
import gradio as gr
def process_audio(file, model, prompt, start, length):
# Dummy processing function to demonstrate functionality
# Replace this with actual audio processing code
processed_audio_path = "goodres.wav"
# Add your audio processing code here
return processed_audio_path
with gr.Blocks() as demo:
gr.Markdown(
"""
# Drums Generation in Different Models
Upload your audio file to process with AudioLDM2 or StableAudio
"""
)
with gr.Row():
with gr.Column():
audio_file = gr.Audio(type="numpy", label="Choose an audio file")
model_choice = gr.Radio(choices=['AudioLDM2', 'StableAudio'], label='Choose a model for processing')
prompt_text = gr.Textbox(label='Enter a prompt for the audio processing')
start_point = gr.Slider(0.0, 60.0, 0.0, step=1.0, label='Choose a starting point for the audio (seconds)')
output_length = gr.Slider(1.0, 60.0, 10.0, step=1.0, label='Choose the length of the output audio (seconds)')
gr.Markdown('**Note:** Longer audio takes more time to generate.')
process_button = gr.Button("Process Audio")
output_audio = gr.Audio(label="Processed Audio")
download_button = gr.File(label="Download Processed Audio")
def on_process(audio_file, model_choice, prompt_text, start_point, output_length):
processed_audio = process_audio(audio_file, model_choice, prompt_text, start_point, output_length)
return processed_audio, processed_audio
process_button.click(on_process, inputs=[audio_file, model_choice, prompt_text, start_point, output_length], outputs=[output_audio, download_button])
gr.Markdown("---")
gr.Markdown("## Examples")
exmples_prompts = ["wiwi", "pipi", "wifi"]
example_titles = ["Original Audio", "Separated Audio", "AudioLDM2", "StableAudio"]
for prompt in exmples_prompts:
with gr.Group():
gr.Markdown(f"**Prompt: {prompt}**")
with gr.Row():
for title in example_titles:
with gr.Column():
gr.Markdown(f"**{title}**")
gr.Audio("goodres.wav", label=f"{title} Audio")
gr.Markdown("---")
gr.Markdown("## Useful Links")
links = [
{"url": "https://example.com", "type": "Regular Website", "text": "This is a regular website"},
{"url": "https://github.com/example", "type": "GitHub", "text": "This is a GitHub repository"},
{"url": "https://colab.research.google.com", "type": "Google Colab", "text": "This is a Google Colab link"}
]
logo_urls = {
"GitHub": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"Google Colab": "https://colab.research.google.com/img/colab_favicon_256px.png"
}
for link in links:
if link["type"] in logo_urls:
gr.HTML(f'<div style="display: flex; align-items: center;"><img src="{logo_urls[link["type"]]}" alt="{link["type"]} logo" width="24" style="margin-right: 10px;"><a href="{link["url"]}" target="_blank">{link["text"]}</a> - <i>{link["type"]}</i></div>')
else:
gr.Markdown(f"[{link['text']}]({link['url']}) - *{link['type']}*")
gr.Markdown("""
<div style="text-align: center; padding: 20px; background: rgba(0, 0, 0, 0.7); color: white; border-top: 1px solid #ddd; margin-top: 30px;">
Made with ❤️ using Gradio
</div>
""")
demo.launch()