File size: 3,160 Bytes
34e8925
 
 
2f717a0
34e8925
 
 
 
 
 
 
 
 
c75e2b0
34e8925
 
 
 
de8428e
c75e2b0
de8428e
 
 
 
c75e2b0
 
 
 
de8428e
34e8925
 
 
 
2f717a0
 
 
34e8925
 
 
5f3a8eb
8348601
 
5f3a8eb
 
 
 
8348601
 
 
5f3a8eb
8348601
de8428e
5f3a8eb
 
8348601
5f3a8eb
de8428e
5f3a8eb
de8428e
8348601
 
 
c75e2b0
8348601
5f3a8eb
 
 
c75e2b0
 
8348601
 
c75e2b0
 
 
 
 
 
8348601
 
 
c75e2b0
34e8925
 
2f717a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import gradio as gr
import torch
import torchaudio
import os  # <-- फाइल का नाम निकालने के लिए इसे इम्पोर्ट किया है

# PyTorch Hub se Silero VAD model load karna
model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
                              model='silero_vad',
                              force_reload=False,
                              trust_repo=True)

(get_speech_timestamps, save_audio, read_audio, VADIterator, collect_chunks) = utils

def remove_silence(audio_path):
    if audio_path is None:
        return None
        
    wav = read_audio(audio_path, sampling_rate=16000)
    
    # 🔥 YAHAN EXTREME MODE ON KIYA HAI 🔥
    speech_timestamps = get_speech_timestamps(
        wav, 
        model, 
        sampling_rate=16000,
        threshold=0.8,                # Confidence high kar diya (choti aawazon ko ignore karega)
        min_silence_duration_ms=10,   # 10ms gap bhi cut
        speech_pad_ms=0,              # ZERO padding (Safety margin hata diya)
        min_speech_duration_ms=50     # Agar 50ms se choti aawaz hai, toh use noise maan kar uda dega
    )

    if not speech_timestamps:
        return audio_path 

    # 👇 बदलाव यहाँ किया गया है: ओरिजिनल फाइल का नाम इस्तेमाल कर रहे हैं
    output_file = os.path.basename(audio_path)
    
    save_audio(output_file, collect_chunks(speech_timestamps, wav), sampling_rate=16000)
    return output_file

# ---- RGB Animation aur MS Font ke liye Custom CSS ----
css = """
@keyframes rgb-glow {
    0% { color: #ff0000; text-shadow: 0 0 10px #ff0000; }
    33% { color: #00ff00; text-shadow: 0 0 10px #00ff00; }
    66% { color: #0000ff; text-shadow: 0 0 10px #0000ff; }
    100% { color: #ff0000; text-shadow: 0 0 10px #ff0000; }
}
.deepu-brand {
    text-align: center;
    font-size: 28px;
    font-weight: bold;
    font-family: 'Comic Sans MS', 'Trebuchet MS', sans-serif;
    animation: rgb-glow 2.5s linear infinite;
    padding: 12px;
    letter-spacing: 2px;
    margin: 15px 0;
    border: 2px dashed #ddd;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.02);
}
"""

# ---- Gradio Blocks (Advanced UI) ----
with gr.Blocks(css=css, title="AI Silence Remover") as iface:
    
    gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
    
    gr.Markdown("<h1 style='text-align: center;'>🎙️ AI Silence Remover (Extreme Mode 🔥)</h1>")
    gr.Markdown("<p style='text-align: center;'>Yeh version zero gap chhodega! Ekdum border-to-border sharp cuts ke liye.</p>")
    
    with gr.Row():
        audio_in = gr.Audio(type="filepath", label="Raw Audio Upload Karein")
    
    submit_btn = gr.Button("Cut Silence (Extreme)", variant="primary")
    
    with gr.Row():
        audio_out = gr.Audio(type="filepath", label="Processed Audio (Zero Gaps)")
    
    gr.HTML('<div class="deepu-brand">✨ Made by Deepu ✨</div>')
    
    submit_btn.click(fn=remove_silence, inputs=audio_in, outputs=audio_out)

if __name__ == "__main__":
    iface.launch()