Update app.py
Browse files
app.py
CHANGED
|
@@ -79,6 +79,69 @@ def process_audio(audio_file, seconds=0.05):
|
|
| 79 |
|
| 80 |
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
def ui():
|
| 83 |
theme = gr.themes.Soft(
|
| 84 |
font=[gr.themes.GoogleFont("Source Sans Pro"), "Arial", "sans-serif"]
|
|
@@ -87,25 +150,36 @@ def ui():
|
|
| 87 |
css = """
|
| 88 |
.gradio-container {max-width: none !important;}
|
| 89 |
.tab-content {padding: 20px;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
"""
|
| 91 |
|
| 92 |
with gr.Blocks(theme=theme, css=css) as demo:
|
| 93 |
-
|
| 94 |
-
#
|
| 95 |
-
# # Remove Silence From Audio
|
| 96 |
-
# Upload an MP3 or WAV file, and it will remove silent parts from it.
|
| 97 |
-
# """
|
| 98 |
-
# )
|
| 99 |
gr.HTML("""
|
| 100 |
<div style="text-align:center; margin:20px auto; max-width:800px;">
|
| 101 |
<h1 style="font-size:2.4em; margin-bottom:6px;">
|
| 102 |
π Remove Silence From Audio
|
| 103 |
</h1>
|
| 104 |
-
|
| 105 |
<p style="font-size:1.05em; color:#555; margin:0 0 10px;">
|
| 106 |
Upload an MP3 or WAV file, and it will remove silent parts from it.
|
| 107 |
</p>
|
| 108 |
-
|
| 109 |
<p style="font-size:0.9em; color:#777;">
|
| 110 |
Made by
|
| 111 |
<a href="https://github.com/NeuralFalconYT" target="_blank" style="text-decoration:none;">
|
|
@@ -116,6 +190,7 @@ def ui():
|
|
| 116 |
""")
|
| 117 |
|
| 118 |
with gr.Row():
|
|
|
|
| 119 |
with gr.Column(scale=1):
|
| 120 |
audio_input = gr.Audio(
|
| 121 |
label="Upload Audio",
|
|
@@ -128,22 +203,25 @@ def ui():
|
|
| 128 |
value=0.05
|
| 129 |
)
|
| 130 |
|
| 131 |
-
submit_btn = gr.Button(
|
|
|
|
|
|
|
|
|
|
| 132 |
|
|
|
|
| 133 |
with gr.Column(scale=1):
|
| 134 |
audio_output = gr.Audio(label="Play Audio")
|
| 135 |
file_output = gr.File(label="Download Audio File")
|
| 136 |
duration_output = gr.Textbox(label="Duration")
|
| 137 |
|
| 138 |
submit_btn.click(
|
| 139 |
-
fn=process_audio,
|
| 140 |
inputs=[audio_input, silence_threshold],
|
| 141 |
outputs=[audio_output, file_output, duration_output]
|
| 142 |
)
|
| 143 |
|
| 144 |
return demo
|
| 145 |
|
| 146 |
-
|
| 147 |
import click
|
| 148 |
@click.command()
|
| 149 |
@click.option("--debug", is_flag=True, default=False, help="Enable debug mode.")
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
+
# def ui():
|
| 83 |
+
# theme = gr.themes.Soft(
|
| 84 |
+
# font=[gr.themes.GoogleFont("Source Sans Pro"), "Arial", "sans-serif"]
|
| 85 |
+
# )
|
| 86 |
+
|
| 87 |
+
# css = """
|
| 88 |
+
# .gradio-container {max-width: none !important;}
|
| 89 |
+
# .tab-content {padding: 20px;}
|
| 90 |
+
# """
|
| 91 |
+
|
| 92 |
+
# with gr.Blocks(theme=theme, css=css) as demo:
|
| 93 |
+
# # gr.Markdown(
|
| 94 |
+
# # """
|
| 95 |
+
# # # Remove Silence From Audio
|
| 96 |
+
# # Upload an MP3 or WAV file, and it will remove silent parts from it.
|
| 97 |
+
# # """
|
| 98 |
+
# # )
|
| 99 |
+
# gr.HTML("""
|
| 100 |
+
# <div style="text-align:center; margin:20px auto; max-width:800px;">
|
| 101 |
+
# <h1 style="font-size:2.4em; margin-bottom:6px;">
|
| 102 |
+
# π Remove Silence From Audio
|
| 103 |
+
# </h1>
|
| 104 |
+
|
| 105 |
+
# <p style="font-size:1.05em; color:#555; margin:0 0 10px;">
|
| 106 |
+
# Upload an MP3 or WAV file, and it will remove silent parts from it.
|
| 107 |
+
# </p>
|
| 108 |
+
|
| 109 |
+
# <p style="font-size:0.9em; color:#777;">
|
| 110 |
+
# Made by
|
| 111 |
+
# <a href="https://github.com/NeuralFalconYT" target="_blank" style="text-decoration:none;">
|
| 112 |
+
# NeuralFalconYT
|
| 113 |
+
# </a>
|
| 114 |
+
# </p>
|
| 115 |
+
# </div>
|
| 116 |
+
# """)
|
| 117 |
+
|
| 118 |
+
# with gr.Row():
|
| 119 |
+
# with gr.Column(scale=1):
|
| 120 |
+
# audio_input = gr.Audio(
|
| 121 |
+
# label="Upload Audio",
|
| 122 |
+
# type="filepath",
|
| 123 |
+
# sources=["upload", "microphone"]
|
| 124 |
+
# )
|
| 125 |
+
|
| 126 |
+
# silence_threshold = gr.Number(
|
| 127 |
+
# label="Keep Silence Upto (In seconds)",
|
| 128 |
+
# value=0.05
|
| 129 |
+
# )
|
| 130 |
+
|
| 131 |
+
# submit_btn = gr.Button("Remove Silence")
|
| 132 |
+
|
| 133 |
+
# with gr.Column(scale=1):
|
| 134 |
+
# audio_output = gr.Audio(label="Play Audio")
|
| 135 |
+
# file_output = gr.File(label="Download Audio File")
|
| 136 |
+
# duration_output = gr.Textbox(label="Duration")
|
| 137 |
+
|
| 138 |
+
# submit_btn.click(
|
| 139 |
+
# fn=process_audio,
|
| 140 |
+
# inputs=[audio_input, silence_threshold],
|
| 141 |
+
# outputs=[audio_output, file_output, duration_output]
|
| 142 |
+
# )
|
| 143 |
+
|
| 144 |
+
# return demo
|
| 145 |
def ui():
|
| 146 |
theme = gr.themes.Soft(
|
| 147 |
font=[gr.themes.GoogleFont("Source Sans Pro"), "Arial", "sans-serif"]
|
|
|
|
| 150 |
css = """
|
| 151 |
.gradio-container {max-width: none !important;}
|
| 152 |
.tab-content {padding: 20px;}
|
| 153 |
+
|
| 154 |
+
/* Primary button - BLUE by default */
|
| 155 |
+
button.primary {
|
| 156 |
+
background-color: #2563eb !important;
|
| 157 |
+
color: white !important;
|
| 158 |
+
font-weight: 600;
|
| 159 |
+
border: none !important;
|
| 160 |
+
border-radius: 10px;
|
| 161 |
+
padding: 12px 18px;
|
| 162 |
+
font-size: 1.05em;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
button.primary:hover {
|
| 166 |
+
background-color: #1e40af !important;
|
| 167 |
+
}
|
| 168 |
"""
|
| 169 |
|
| 170 |
with gr.Blocks(theme=theme, css=css) as demo:
|
| 171 |
+
|
| 172 |
+
# Header
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
gr.HTML("""
|
| 174 |
<div style="text-align:center; margin:20px auto; max-width:800px;">
|
| 175 |
<h1 style="font-size:2.4em; margin-bottom:6px;">
|
| 176 |
π Remove Silence From Audio
|
| 177 |
</h1>
|
| 178 |
+
|
| 179 |
<p style="font-size:1.05em; color:#555; margin:0 0 10px;">
|
| 180 |
Upload an MP3 or WAV file, and it will remove silent parts from it.
|
| 181 |
</p>
|
| 182 |
+
|
| 183 |
<p style="font-size:0.9em; color:#777;">
|
| 184 |
Made by
|
| 185 |
<a href="https://github.com/NeuralFalconYT" target="_blank" style="text-decoration:none;">
|
|
|
|
| 190 |
""")
|
| 191 |
|
| 192 |
with gr.Row():
|
| 193 |
+
# LEFT: Inputs
|
| 194 |
with gr.Column(scale=1):
|
| 195 |
audio_input = gr.Audio(
|
| 196 |
label="Upload Audio",
|
|
|
|
| 203 |
value=0.05
|
| 204 |
)
|
| 205 |
|
| 206 |
+
submit_btn = gr.Button(
|
| 207 |
+
"π Remove Silence",
|
| 208 |
+
variant="primary"
|
| 209 |
+
)
|
| 210 |
|
| 211 |
+
# RIGHT: Outputs
|
| 212 |
with gr.Column(scale=1):
|
| 213 |
audio_output = gr.Audio(label="Play Audio")
|
| 214 |
file_output = gr.File(label="Download Audio File")
|
| 215 |
duration_output = gr.Textbox(label="Duration")
|
| 216 |
|
| 217 |
submit_btn.click(
|
| 218 |
+
fn=process_audio, # <-- your function
|
| 219 |
inputs=[audio_input, silence_threshold],
|
| 220 |
outputs=[audio_output, file_output, duration_output]
|
| 221 |
)
|
| 222 |
|
| 223 |
return demo
|
| 224 |
|
|
|
|
| 225 |
import click
|
| 226 |
@click.command()
|
| 227 |
@click.option("--debug", is_flag=True, default=False, help="Enable debug mode.")
|