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('
✨ Made by Deepu ✨
') gr.Markdown("

🎙️ AI Silence Remover (Extreme Mode 🔥)

") gr.Markdown("

Yeh version zero gap chhodega! Ekdum border-to-border sharp cuts ke liye.

") 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('
✨ Made by Deepu ✨
') submit_btn.click(fn=remove_silence, inputs=audio_in, outputs=audio_out) if __name__ == "__main__": iface.launch()