michaelpiro1 commited on
Commit
da8b859
·
verified ·
1 Parent(s): 364b18e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -66
app.py CHANGED
@@ -7,70 +7,23 @@ def process_audio(file, model, prompt, start, length):
7
  # Add your audio processing code here
8
  return processed_audio_path
9
 
10
-
11
- with gr.Blocks() as demo:
12
- gr.Markdown(
13
- """
14
- # Drums Generation in Different Models
15
- Upload your audio file to process with AudioLDM2 or StableAudio
16
- """
17
- )
18
-
19
- with gr.Row():
20
- with gr.Column():
21
- audio_file = gr.Audio(type="numpy", label="Choose an audio file")
22
- model_choice = gr.Radio(choices=['AudioLDM2', 'StableAudio'], label='Choose a model for processing')
23
- prompt_text = gr.Textbox(label='Enter a prompt for the audio processing')
24
- start_point = gr.Slider(0.0, 60.0, 0.0, step=1.0, label='Choose a starting point for the audio (seconds)')
25
- output_length = gr.Slider(1.0, 60.0, 10.0, step=1.0, label='Choose the length of the output audio (seconds)')
26
- gr.Markdown('**Note:** Longer audio takes more time to generate.')
27
-
28
- process_button = gr.Button("Process Audio")
29
- output_audio = gr.Audio(label="Processed Audio")
30
- download_button = gr.File(label="Download Processed Audio")
31
-
32
- def on_process(audio_file, model_choice, prompt_text, start_point, output_length):
33
- processed_audio = process_audio(audio_file, model_choice, prompt_text, start_point, output_length)
34
- return processed_audio, processed_audio
35
-
36
- process_button.click(on_process, inputs=[audio_file, model_choice, prompt_text, start_point, output_length], outputs=[output_audio, download_button])
37
-
38
- gr.Markdown("---")
39
- gr.Markdown("## Examples")
40
-
41
- exmples_prompts = ["wiwi", "pipi", "wifi"]
42
- example_titles = ["Original Audio", "Separated Audio", "AudioLDM2", "StableAudio"]
43
-
44
- for prompt in exmples_prompts:
45
- with gr.Group():
46
- gr.Markdown(f"**Prompt: {prompt}**")
47
- with gr.Row():
48
- for title in example_titles:
49
- with gr.Column():
50
- gr.Markdown(f"**{title}**")
51
- gr.Audio("goodres.wav", label=f"{title} Audio")
52
-
53
- gr.Markdown("---")
54
- gr.Markdown("## Useful Links")
55
- links = [
56
- {"url": "https://example.com", "type": "Regular Website", "text": "This is a regular website"},
57
- {"url": "https://github.com/example", "type": "GitHub", "text": "This is a GitHub repository"},
58
- {"url": "https://colab.research.google.com", "type": "Google Colab", "text": "This is a Google Colab link"}
59
- ]
60
- logo_urls = {
61
- "GitHub": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
62
- "Google Colab": "https://colab.research.google.com/img/colab_favicon_256px.png"
63
- }
64
- for link in links:
65
- if link["type"] in logo_urls:
66
- 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>')
67
- else:
68
- gr.Markdown(f"[{link['text']}]({link['url']}) - *{link['type']}*")
69
-
70
- gr.Markdown("""
71
- <div style="text-align: center; padding: 20px; background: rgba(0, 0, 0, 0.7); color: white; border-top: 1px solid #ddd; margin-top: 30px;">
72
- Made with ❤️ using Gradio
73
- </div>
74
- """)
75
-
76
  demo.launch()
 
7
  # Add your audio processing code here
8
  return processed_audio_path
9
 
10
+ demo = gr.Interface(
11
+ fn=process_audio,
12
+ inputs=[
13
+ gr.Audio(type="file", label="Upload Audio File"),
14
+ gr.Radio(choices=['AudioLDM2', 'StableAudio'], label='Choose a Model for Processing'),
15
+ gr.Textbox(label="Prompt", placeholder="Enter your text prompt here"),
16
+ gr.Slider(0.0, 60.0, value=0.0, step=1.0, label="Starting Point (seconds)"),
17
+ gr.Slider(1.0, 60.0, value=10.0, step=1.0, label="Output Length (seconds)", info="Longer audio takes more time to generate")
18
+ ],
19
+ outputs=gr.Audio(type="file", label="Processed Audio"),
20
+ title="Drums Generation in Different Models",
21
+ description="Upload your audio file and process it with AudioLDM2 or StableAudio based on your prompt and settings.",
22
+ examples=[
23
+ ["example.wav", "AudioLDM2", "Generate a rock beat", 0.0, 10.0],
24
+ ["example.wav", "StableAudio", "Create a serene soundscape", 5.0, 15.0],
25
+ ["example.wav", "AudioLDM2", "Simulate a forest ambiance", 10.0, 20.0],
26
+ ["example.wav", "StableAudio", "Recreate a gentle rainfall", 0.0, 25.0]
27
+ ]
28
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  demo.launch()