Offex commited on
Commit
837693b
·
verified ·
1 Parent(s): fde739e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -16
app.py CHANGED
@@ -10,21 +10,21 @@ model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
10
 
11
  (get_speech_timestamps, save_audio, read_audio, VADIterator, collect_chunks) = utils
12
 
13
- def remove_silence(audio_path):
14
  if audio_path is None:
15
  return None
16
 
17
  wav = read_audio(audio_path, sampling_rate=16000)
18
 
19
- # 🔥 YAHAN EXTREME MODE ON KIYA HAI 🔥
20
  speech_timestamps = get_speech_timestamps(
21
  wav,
22
  model,
23
  sampling_rate=16000,
24
- threshold=0.8, # Confidence high kar diya (choti aawazon ko ignore karega)
25
- min_silence_duration_ms=8, # 10ms gap bhi cut
26
- speech_pad_ms=0, # ZERO padding (Safety margin hata diya)
27
- min_speech_duration_ms=50 # Agar 50ms se choti aawaz hai, toh use noise maan kar uda dega
28
  )
29
 
30
  if not speech_timestamps:
@@ -57,25 +57,36 @@ css = """
57
  }
58
  """
59
 
60
- # ---- Gradio Blocks (Advanced UI) ----
61
  with gr.Blocks(css=css, title="AI Silence Remover") as iface:
62
 
63
  gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
64
 
65
- gr.Markdown("<h1 style='text-align: center;'>🎙️ AI Silence Remover (Extreme Mode 🔥)</h1>")
66
- gr.Markdown("<p style='text-align: center;'>Yeh version zero gap chhodega! Ekdum border-to-border sharp cuts ke liye.</p>")
67
 
68
  with gr.Row():
69
- audio_in = gr.Audio(type="filepath", label="Raw Audio Upload Karein")
70
-
71
- submit_btn = gr.Button("Cut Silence (Extreme)", variant="primary")
72
-
73
- with gr.Row():
74
- audio_out = gr.Audio(type="filepath", label="Processed Audio (Zero Gaps)")
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
77
 
78
- submit_btn.click(fn=remove_silence, inputs=audio_in, outputs=audio_out)
79
 
80
  if __name__ == "__main__":
81
  iface.launch()
 
10
 
11
  (get_speech_timestamps, save_audio, read_audio, VADIterator, collect_chunks) = utils
12
 
13
+ def remove_silence(audio_path, vad_threshold, min_silence, padding):
14
  if audio_path is None:
15
  return None
16
 
17
  wav = read_audio(audio_path, sampling_rate=16000)
18
 
19
+ # Ab values sliders se aayengi!
20
  speech_timestamps = get_speech_timestamps(
21
  wav,
22
  model,
23
  sampling_rate=16000,
24
+ threshold=vad_threshold,
25
+ min_silence_duration_ms=int(min_silence),
26
+ speech_pad_ms=int(padding),
27
+ min_speech_duration_ms=50
28
  )
29
 
30
  if not speech_timestamps:
 
57
  }
58
  """
59
 
60
+ # ---- Gradio Blocks (Advanced UI with Sliders) ----
61
  with gr.Blocks(css=css, title="AI Silence Remover") as iface:
62
 
63
  gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
64
 
65
+ gr.Markdown("<h1 style='text-align: center;'>🎙️ AI Silence Remover (Pro Control 🎛️)</h1>")
66
+ gr.Markdown("<p style='text-align: center;'>Ab aap khud sliders se control karein ki kitni strict cutting karni hai!</p>")
67
 
68
  with gr.Row():
69
+ with gr.Column():
70
+ audio_in = gr.Audio(type="filepath", label="1. Raw Audio Upload Karein")
71
+
72
+ gr.Markdown("### ⚙️ Advance Settings (Inhe adjust karein)")
73
+ # Slider 1: AI Strictness (Maine default 0.90 kar diya hai, pehle 0.80 tha)
74
+ vad_threshold = gr.Slider(minimum=0.1, maximum=0.99, value=0.90, step=0.05, label="AI Strictness (Jitna zyada, utni strict cutting)")
75
+
76
+ # Slider 2: Min Silence Duration
77
+ min_silence = gr.Slider(minimum=0, maximum=500, value=10, step=10, label="Min Silence Duration (ms) - 0 rakhein sharpest cut ke liye")
78
+
79
+ # Slider 3: Padding
80
+ padding = gr.Slider(minimum=0, maximum=200, value=0, step=10, label="Speech Padding (ms) - Aawaz ke aage-peeche ki safety jagah")
81
+
82
+ submit_btn = gr.Button("Cut Silence", variant="primary")
83
+
84
+ with gr.Column():
85
+ audio_out = gr.Audio(type="filepath", label="2. Processed Audio (Zero Gaps)")
86
 
87
  gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
88
 
89
+ submit_btn.click(fn=remove_silence, inputs=[audio_in, vad_threshold, min_silence, padding], outputs=audio_out)
90
 
91
  if __name__ == "__main__":
92
  iface.launch()