Kalp97 commited on
Commit
59d7784
·
verified ·
1 Parent(s): 9e8bef9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +151 -10
app.py CHANGED
@@ -14,19 +14,160 @@ def transcribe(file):
14
  return "Please upload a video or audio file."
15
  try:
16
  m = load_model()
17
- result = m.transcribe(file, language="en", verbose=False)
18
  return result["text"].strip()
19
  except Exception as e:
20
  return f"Error: {str(e)}"
21
 
22
- demo = gr.Interface(
23
- fn=transcribe,
24
- inputs=gr.Audio(type="filepath", label="Upload your video or audio file"),
25
- outputs=gr.Textbox(label="Transcript", lines=15),
26
- title="🎙️ AI Video Transcriber",
27
- description="Upload any video or audio file and get a full transcript powered by OpenAI Whisper.",
28
- theme=gr.themes.Soft()
29
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  if __name__ == "__main__":
32
- demo.launch()
 
14
  return "Please upload a video or audio file."
15
  try:
16
  m = load_model()
17
+ result = m.transcribe(file.name, language="en", verbose=False)
18
  return result["text"].strip()
19
  except Exception as e:
20
  return f"Error: {str(e)}"
21
 
22
+ custom_css = """
23
+ @import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500&display=swap');
24
+
25
+ * { box-sizing: border-box; }
26
+
27
+ body, .gradio-container {
28
+ background: #0a0a0a !important;
29
+ font-family: 'DM Sans', sans-serif !important;
30
+ }
31
+
32
+ .gradio-container {
33
+ max-width: 920px !important;
34
+ margin: 0 auto !important;
35
+ padding: 48px 24px !important;
36
+ }
37
+
38
+ .prose h1 {
39
+ font-family: 'DM Serif Display', serif !important;
40
+ font-size: 2.8rem !important;
41
+ font-weight: 400 !important;
42
+ color: #f0ece2 !important;
43
+ letter-spacing: -0.02em !important;
44
+ line-height: 1.1 !important;
45
+ margin-bottom: 0 !important;
46
+ }
47
+
48
+ .prose p {
49
+ font-family: 'DM Sans', sans-serif !important;
50
+ color: #6b6860 !important;
51
+ font-size: 0.95rem !important;
52
+ font-weight: 300 !important;
53
+ margin-top: 10px !important;
54
+ }
55
+
56
+ .contain, .gap {
57
+ background: transparent !important;
58
+ border: none !important;
59
+ gap: 20px !important;
60
+ }
61
+
62
+ .block {
63
+ background: #111111 !important;
64
+ border: 1px solid #1e1e1e !important;
65
+ border-radius: 16px !important;
66
+ }
67
+
68
+ .block label span {
69
+ font-family: 'DM Sans', sans-serif !important;
70
+ font-size: 0.75rem !important;
71
+ font-weight: 500 !important;
72
+ color: #6b6860 !important;
73
+ text-transform: uppercase !important;
74
+ letter-spacing: 0.1em !important;
75
+ }
76
+
77
+ textarea {
78
+ background: transparent !important;
79
+ color: #f0ece2 !important;
80
+ font-family: 'DM Sans', sans-serif !important;
81
+ font-size: 0.95rem !important;
82
+ line-height: 1.8 !important;
83
+ font-weight: 300 !important;
84
+ border: none !important;
85
+ }
86
+
87
+ .file-preview, .upload-container {
88
+ background: transparent !important;
89
+ border: none !important;
90
+ color: #555 !important;
91
+ }
92
+
93
+ button.primary {
94
+ background: #c9a96e !important;
95
+ border: none !important;
96
+ border-radius: 12px !important;
97
+ color: #0a0a0a !important;
98
+ font-family: 'DM Sans', sans-serif !important;
99
+ font-size: 0.8rem !important;
100
+ font-weight: 500 !important;
101
+ letter-spacing: 0.1em !important;
102
+ text-transform: uppercase !important;
103
+ padding: 14px 28px !important;
104
+ transition: all 0.2s ease !important;
105
+ }
106
+
107
+ button.primary:hover {
108
+ background: #d4b87e !important;
109
+ transform: translateY(-1px) !important;
110
+ box-shadow: 0 4px 20px rgba(201,169,110,0.25) !important;
111
+ }
112
+
113
+ button.secondary {
114
+ background: transparent !important;
115
+ border: 1px solid #222 !important;
116
+ border-radius: 12px !important;
117
+ color: #555 !important;
118
+ font-family: 'DM Sans', sans-serif !important;
119
+ font-size: 0.8rem !important;
120
+ font-weight: 500 !important;
121
+ letter-spacing: 0.1em !important;
122
+ text-transform: uppercase !important;
123
+ transition: all 0.2s ease !important;
124
+ }
125
+
126
+ button.secondary:hover {
127
+ border-color: #444 !important;
128
+ color: #f0ece2 !important;
129
+ }
130
+
131
+ footer { display: none !important; }
132
+
133
+ textarea::-webkit-scrollbar { width: 4px; }
134
+ textarea::-webkit-scrollbar-track { background: transparent; }
135
+ textarea::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }
136
+
137
+ .gradio-container::before {
138
+ content: '';
139
+ display: block;
140
+ width: 36px;
141
+ height: 2px;
142
+ background: #c9a96e;
143
+ margin-bottom: 28px;
144
+ }
145
+ """
146
+
147
+ with gr.Blocks(css=custom_css, title="KalpTranscript") as demo:
148
+ gr.Markdown("""
149
+ # KalpTranscript
150
+ Turn any video or audio into clean, readable text — powered by OpenAI Whisper.
151
+ """)
152
+
153
+ with gr.Row():
154
+ with gr.Column():
155
+ file_input = gr.File(
156
+ label="Drop your file here",
157
+ file_types=["video", "audio"]
158
+ )
159
+ with gr.Row():
160
+ clear_btn = gr.ClearButton(value="Clear")
161
+ submit_btn = gr.Button("Transcribe →", variant="primary")
162
+
163
+ with gr.Column():
164
+ output = gr.Textbox(
165
+ label="Transcript",
166
+ lines=14,
167
+ placeholder="Your transcript will appear here..."
168
+ )
169
+
170
+ submit_btn.click(fn=transcribe, inputs=file_input, outputs=output)
171
 
172
  if __name__ == "__main__":
173
+ demo.launch()