File size: 3,428 Bytes
3a80d12
 
 
 
 
67cd354
3a80d12
 
 
ee7a8d0
3a80d12
 
 
 
 
 
 
 
ee7a8d0
 
 
 
 
 
 
 
3a80d12
ee7a8d0
 
 
3a80d12
ee7a8d0
 
 
3a80d12
ee7a8d0
3a80d12
ee7a8d0
 
3a80d12
ee7a8d0
 
 
 
 
 
 
 
 
 
 
3a80d12
ee7a8d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3a80d12
ee7a8d0
 
 
 
 
3a80d12
ee7a8d0
3a80d12
4ba367a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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()


main()