Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,16 @@ def remove_silence(audio_path):
|
|
| 15 |
return None
|
| 16 |
|
| 17 |
wav = read_audio(audio_path, sampling_rate=16000)
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
if not speech_timestamps:
|
| 21 |
return audio_path
|
|
@@ -36,25 +45,24 @@ css = """
|
|
| 36 |
text-align: center;
|
| 37 |
font-size: 28px;
|
| 38 |
font-weight: bold;
|
| 39 |
-
font-family: 'Comic Sans MS', 'Trebuchet MS', sans-serif;
|
| 40 |
animation: rgb-glow 2.5s linear infinite;
|
| 41 |
padding: 12px;
|
| 42 |
letter-spacing: 2px;
|
| 43 |
margin: 15px 0;
|
| 44 |
-
border: 2px dashed #ddd;
|
| 45 |
border-radius: 10px;
|
| 46 |
-
background-color: rgba(0, 0, 0, 0.02);
|
| 47 |
}
|
| 48 |
"""
|
| 49 |
|
| 50 |
# ---- Gradio Blocks (Advanced UI) ----
|
| 51 |
with gr.Blocks(css=css, title="AI Silence Remover") as iface:
|
| 52 |
|
| 53 |
-
# 1. TOP WALA ANIMATED TAG
|
| 54 |
gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
|
| 55 |
|
| 56 |
-
gr.Markdown("<h1 style='text-align: center;'>🎙️ AI Silence Remover (
|
| 57 |
-
gr.Markdown("<p style='text-align: center;'>Apni audio upload karein
|
| 58 |
|
| 59 |
with gr.Row():
|
| 60 |
audio_in = gr.Audio(type="filepath", label="Raw Audio Upload Karein")
|
|
@@ -64,10 +72,8 @@ with gr.Blocks(css=css, title="AI Silence Remover") as iface:
|
|
| 64 |
with gr.Row():
|
| 65 |
audio_out = gr.Audio(type="filepath", label="Processed Audio (Without Silence)")
|
| 66 |
|
| 67 |
-
# 2. BOTTOM WALA ANIMATED TAG
|
| 68 |
gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
|
| 69 |
|
| 70 |
-
# Button ko function ke sath jodna
|
| 71 |
submit_btn.click(fn=remove_silence, inputs=audio_in, outputs=audio_out)
|
| 72 |
|
| 73 |
if __name__ == "__main__":
|
|
|
|
| 15 |
return None
|
| 16 |
|
| 17 |
wav = read_audio(audio_path, sampling_rate=16000)
|
| 18 |
+
|
| 19 |
+
# 🔴 YAHAN MAGIC HUA HAI: AI ko aur strict banaya gaya hai 🔴
|
| 20 |
+
speech_timestamps = get_speech_timestamps(
|
| 21 |
+
wav,
|
| 22 |
+
model,
|
| 23 |
+
sampling_rate=16000,
|
| 24 |
+
threshold=0.5, # Aawaz pehchanne ki limit
|
| 25 |
+
min_silence_duration_ms=50, # Agar 50 millisecond ka bhi gap ho, toh use cut kar do (Pehle ye zyada tha)
|
| 26 |
+
speech_pad_ms=10 # Aawaz ke aage-peeche ka gap sirf 10ms rakha hai (Pehle AI zyada gap chhod raha tha)
|
| 27 |
+
)
|
| 28 |
|
| 29 |
if not speech_timestamps:
|
| 30 |
return audio_path
|
|
|
|
| 45 |
text-align: center;
|
| 46 |
font-size: 28px;
|
| 47 |
font-weight: bold;
|
| 48 |
+
font-family: 'Comic Sans MS', 'Trebuchet MS', sans-serif;
|
| 49 |
animation: rgb-glow 2.5s linear infinite;
|
| 50 |
padding: 12px;
|
| 51 |
letter-spacing: 2px;
|
| 52 |
margin: 15px 0;
|
| 53 |
+
border: 2px dashed #ddd;
|
| 54 |
border-radius: 10px;
|
| 55 |
+
background-color: rgba(0, 0, 0, 0.02);
|
| 56 |
}
|
| 57 |
"""
|
| 58 |
|
| 59 |
# ---- Gradio Blocks (Advanced UI) ----
|
| 60 |
with gr.Blocks(css=css, title="AI Silence Remover") as iface:
|
| 61 |
|
|
|
|
| 62 |
gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
|
| 63 |
|
| 64 |
+
gr.Markdown("<h1 style='text-align: center;'>🎙️ AI Silence Remover (Aggressive Mode)</h1>")
|
| 65 |
+
gr.Markdown("<p style='text-align: center;'>Apni audio upload karein. Yeh version chote se chote gap ko bhi cut karega!</p>")
|
| 66 |
|
| 67 |
with gr.Row():
|
| 68 |
audio_in = gr.Audio(type="filepath", label="Raw Audio Upload Karein")
|
|
|
|
| 72 |
with gr.Row():
|
| 73 |
audio_out = gr.Audio(type="filepath", label="Processed Audio (Without Silence)")
|
| 74 |
|
|
|
|
| 75 |
gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
|
| 76 |
|
|
|
|
| 77 |
submit_btn.click(fn=remove_silence, inputs=audio_in, outputs=audio_out)
|
| 78 |
|
| 79 |
if __name__ == "__main__":
|