TS447 commited on
Commit
71e332d
·
verified ·
1 Parent(s): 225ba43

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +110 -0
app.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from voicefixer import VoiceFixer
3
+ import os
4
+ import torch
5
+
6
+ # --- 1. Setup Logic ---
7
+ device = "cuda" if torch.cuda.is_available() else "cpu"
8
+ print(f"Using device: {device}")
9
+
10
+ # Initialize VoiceFixer
11
+ try:
12
+ vf = VoiceFixer()
13
+ except Exception as e:
14
+ print(f"Error loading VoiceFixer: {e}")
15
+
16
+ def fix_audio_ts(audio_path):
17
+ if audio_path is None:
18
+ return None
19
+
20
+ output_file = "ts_studio_enhanced.wav"
21
+
22
+ # Mode 0: Cleaning + Restoration
23
+ vf.restore(input=audio_path, output=output_file, cuda=(device=='cuda'), mode=0)
24
+
25
+ return output_file
26
+
27
+ # --- 2. Ultra-Premium TS Audio CSS ---
28
+ custom_css = """
29
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;900&display=swap');
30
+
31
+ body, .gradio-container {
32
+ font-family: 'Inter', sans-serif !important;
33
+ background: #0a0a0a !important;
34
+ color: #ffffff !important;
35
+ }
36
+
37
+ #main_card {
38
+ background: rgba(30, 30, 40, 0.8);
39
+ backdrop-filter: blur(30px);
40
+ border: 1px solid rgba(255, 255, 255, 0.15);
41
+ border-radius: 30px;
42
+ padding: 40px;
43
+ box-shadow: 0 0 60px rgba(0, 255, 136, 0.1), inset 0 0 20px rgba(255, 255, 255, 0.05);
44
+ max-width: 800px;
45
+ margin: 40px auto;
46
+ }
47
+
48
+ #logo_text h1 {
49
+ color: #ffffff;
50
+ font-size: 4.5rem !important;
51
+ font-weight: 900;
52
+ text-align: center;
53
+ margin-bottom: 0px;
54
+ letter-spacing: -2px;
55
+ text-shadow: 0 0 25px rgba(0, 255, 136, 0.6);
56
+ }
57
+
58
+ #subtitle_text h3 {
59
+ text-align: center;
60
+ color: #bbbbbb;
61
+ font-size: 1.2rem;
62
+ font-weight: 400;
63
+ margin-top: 10px;
64
+ margin-bottom: 40px;
65
+ letter-spacing: 1px;
66
+ }
67
+
68
+ .block, .svelte-12cmxck, .form {
69
+ background: rgba(255,255,255,0.03) !important;
70
+ border: 1px solid rgba(255,255,255,0.1) !important;
71
+ border-radius: 20px !important;
72
+ padding: 15px !important;
73
+ }
74
+
75
+ .primary-btn {
76
+ background: linear-gradient(135deg, #00ff88, #00b8ff) !important;
77
+ color: #000 !important;
78
+ border: none !important;
79
+ font-size: 1.2rem !important;
80
+ font-weight: 900 !important;
81
+ padding: 18px !important;
82
+ border-radius: 15px !important;
83
+ box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
84
+ transition: all 0.3s ease;
85
+ margin-top: 20px;
86
+ }
87
+ .primary-btn:hover {
88
+ transform: translateY(-2px);
89
+ box-shadow: 0 0 50px rgba(0, 255, 136, 0.6);
90
+ }
91
+ """
92
+
93
+ # --- 3. Interface ---
94
+ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as app:
95
+
96
+ with gr.Column(elem_id="main_card"):
97
+ gr.Markdown("# TS", elem_id="logo_text")
98
+ gr.Markdown("### PREMIUM VOCAL ENHANCER", elem_id="subtitle_text")
99
+
100
+ gr.Markdown("**🎤 Upload Noisy Audio**")
101
+ inp_audio = gr.Audio(type="filepath", label="Input Audio", sources=["upload", "microphone"])
102
+
103
+ btn = gr.Button("🎹 RESTORE VOICE (Studio Quality)", variant="primary", elem_classes=["primary-btn"])
104
+
105
+ gr.Markdown("**🎧 Enhanced Result (Clean Voice)**")
106
+ out_audio = gr.Audio(type="filepath", label="Studio Output", interactive=False)
107
+
108
+ btn.click(fix_audio_ts, inputs=inp_audio, outputs=out_audio)
109
+
110
+ app.launch()