File size: 3,287 Bytes
71e332d
 
 
 
5f5a68d
 
 
71e332d
5f5a68d
 
 
 
 
 
 
71e332d
 
 
 
 
5f5a68d
 
 
 
71e332d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import gradio as gr
import os
import torch

# --- 1. Setup Logic (Lazy Loading) ---
# Hum model ko globally load nahi karenge taaki app turant start ho jaye
vf_model = None

def get_model():
    global vf_model
    if vf_model is None:
        print("Loading VoiceFixer Model...")
        from voicefixer import VoiceFixer
        vf_model = VoiceFixer()
    return vf_model

def fix_audio_ts(audio_path):
    if audio_path is None:
        return None
    
    # Model load karo (agar pehle se loaded nahi hai)
    vf = get_model()
    
    device = "cuda" if torch.cuda.is_available() else "cpu"
    output_file = "ts_studio_enhanced.wav"
    
    # Mode 0: Cleaning + Restoration
    vf.restore(input=audio_path, output=output_file, cuda=(device=='cuda'), mode=0)
    
    return output_file

# --- 2. Ultra-Premium TS Audio CSS ---
custom_css = """
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;900&display=swap');

body, .gradio-container {
    font-family: 'Inter', sans-serif !important;
    background: #0a0a0a !important;
    color: #ffffff !important;
}

#main_card {
    background: rgba(30, 30, 40, 0.8);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 0 60px rgba(0, 255, 136, 0.1), inset 0 0 20px rgba(255, 255, 255, 0.05);
    max-width: 800px;
    margin: 40px auto;
}

#logo_text h1 {
    color: #ffffff;
    font-size: 4.5rem !important;
    font-weight: 900;
    text-align: center;
    margin-bottom: 0px;
    letter-spacing: -2px;
    text-shadow: 0 0 25px rgba(0, 255, 136, 0.6);
}

#subtitle_text h3 {
    text-align: center;
    color: #bbbbbb;
    font-size: 1.2rem;
    font-weight: 400;
    margin-top: 10px;
    margin-bottom: 40px;
    letter-spacing: 1px;
}

.block, .svelte-12cmxck, .form {
    background: rgba(255,255,255,0.03) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 20px !important;
    padding: 15px !important;
}

.primary-btn {
    background: linear-gradient(135deg, #00ff88, #00b8ff) !important;
    color: #000 !important;
    border: none !important;
    font-size: 1.2rem !important;
    font-weight: 900 !important;
    padding: 18px !important;
    border-radius: 15px !important;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
    transition: all 0.3s ease;
    margin-top: 20px;
}
.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 50px rgba(0, 255, 136, 0.6);
}
"""

# --- 3. Interface ---
with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as app:
    
    with gr.Column(elem_id="main_card"):
        gr.Markdown("# TS", elem_id="logo_text")
        gr.Markdown("### PREMIUM VOCAL ENHANCER", elem_id="subtitle_text")
        
        gr.Markdown("**🎤 Upload Noisy Audio**")
        inp_audio = gr.Audio(type="filepath", label="Input Audio", sources=["upload", "microphone"])
        
        btn = gr.Button("🎹 RESTORE VOICE (Studio Quality)", variant="primary", elem_classes=["primary-btn"])
        
        gr.Markdown("**🎧 Enhanced Result (Clean Voice)**")
        out_audio = gr.Audio(type="filepath", label="Studio Output", interactive=False)

    btn.click(fix_audio_ts, inputs=inp_audio, outputs=out_audio)

app.launch()