michaelpiro1 commited on
Commit
ee7a8d0
·
verified ·
1 Parent(s): 4ba367a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -51
app.py CHANGED
@@ -7,7 +7,7 @@ def process_audio(file, model, prompt, start, length):
7
  # Add your audio processing code here
8
  return processed_audio_path
9
 
10
- def main():
11
  with gr.Blocks() as demo:
12
  gr.Markdown(
13
  """
@@ -16,64 +16,64 @@ def main():
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()
77
 
78
 
79
  main()
 
7
  # Add your audio processing code here
8
  return processed_audio_path
9
 
10
+
11
  with gr.Blocks() as demo:
12
  gr.Markdown(
13
  """
 
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()
 
 
 
 
 
 
77
 
78
 
79
  main()