FurqanIshaq commited on
Commit
297323c
·
verified ·
1 Parent(s): a62c338

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py CHANGED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tempfile
2
+ import torchaudio
3
+ import whisper
4
+ import gradio as gr
5
+
6
+ # Load Whisper model
7
+ model = whisper.load_model("base")
8
+
9
+ def transcribe_audio(audio_file):
10
+ # Save uploaded audio
11
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp_wav:
12
+ signal, sr = torchaudio.load(audio_file)
13
+
14
+ # Resample if needed
15
+ if sr != 16000:
16
+ signal = torchaudio.transforms.Resample(sr, 16000)(signal)
17
+ if signal.shape[0] > 1:
18
+ signal = signal.mean(dim=0, keepdim=True)
19
+
20
+ torchaudio.save(tmp_wav.name, signal, 16000)
21
+
22
+ # Transcribe with Whisper
23
+ result = model.transcribe(tmp_wav.name)
24
+ transcript = result['text']
25
+
26
+ # Save transcript to file
27
+ with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:
28
+ f.write(transcript)
29
+ transcript_file_path = f.name
30
+
31
+ return transcript, transcript_file_path
32
+
33
+ # Gradio Interface
34
+ app = gr.Interface(
35
+ fn=transcribe_audio,
36
+ inputs=gr.Audio(type="filepath", label="🎙️ Upload Meeting Audio"),
37
+ outputs=[
38
+ gr.Textbox(label="📝 Transcript", lines=10),
39
+ gr.File(label="⬇️ Download Transcript (.txt)")
40
+ ],
41
+ title="🎧 Meeting Summarizer (STT Only)",
42
+ description="Upload your meeting audio and get a clean transcript you can read and download.",
43
+ theme="soft"
44
+ )
45
+
46
+ app.launch()