NeuralFalcon commited on
Commit
a023ec7
·
verified ·
1 Parent(s): 0980832

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -14
app.py CHANGED
@@ -56,24 +56,94 @@ def process_audio(audio_file, seconds=0.05):
56
  text = f"Old Duration: {before:.3f} seconds \nNew Duration: {after:.3f} seconds"
57
  return output_audio_file, output_audio_file, text
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  def ui():
60
- demo = gr.Interface(
61
- fn=process_audio,
62
- inputs=[
63
- gr.Audio(label="Upload Audio", type="filepath", sources=['upload', 'microphone']),
64
- gr.Number(label="Keep Silence Upto (In seconds)", value=0.05)
65
- ],
66
- outputs=[
67
- gr.Audio(label="Play Audio"),
68
- gr.File(label="Download Audio File"),
69
- gr.Textbox(label="Duration")
70
- ],
71
- title="Remove Silence From Audio",
72
- description="Upload an MP3 or WAV file, and it will remove silent parts from it.",
73
- #theme='NoCrypt/miku'
74
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  return demo
76
 
 
77
  import click
78
  @click.command()
79
  @click.option("--debug", is_flag=True, default=False, help="Enable debug mode.")
 
56
  text = f"Old Duration: {before:.3f} seconds \nNew Duration: {after:.3f} seconds"
57
  return output_audio_file, output_audio_file, text
58
 
59
+ # def ui():
60
+ # theme = gr.themes.Soft(font=[gr.themes.GoogleFont("Source Sans Pro"), "Arial", "sans-serif"])
61
+ # css = ".gradio-container {max-width: none !important;} .tab-content {padding: 20px;}"
62
+ # demo = gr.Interface(
63
+ # fn=process_audio,
64
+ # inputs=[
65
+ # gr.Audio(label="Upload Audio", type="filepath", sources=['upload', 'microphone']),
66
+ # gr.Number(label="Keep Silence Upto (In seconds)", value=0.05)
67
+ # ],
68
+ # outputs=[
69
+ # gr.Audio(label="Play Audio"),
70
+ # gr.File(label="Download Audio File"),
71
+ # gr.Textbox(label="Duration")
72
+ # ],
73
+ # title="Remove Silence From Audio",
74
+ # description="Upload an MP3 or WAV file, and it will remove silent parts from it.",
75
+ # theme=theme,
76
+ # css=css,
77
+ # )
78
+ # return demo
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("Process")
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.")