Spaces:
Sleeping
Sleeping
File size: 1,378 Bytes
297323c |
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 |
import tempfile
import torchaudio
import whisper
import gradio as gr
# Load Whisper model
model = whisper.load_model("base")
def transcribe_audio(audio_file):
# Save uploaded audio
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp_wav:
signal, sr = torchaudio.load(audio_file)
# Resample if needed
if sr != 16000:
signal = torchaudio.transforms.Resample(sr, 16000)(signal)
if signal.shape[0] > 1:
signal = signal.mean(dim=0, keepdim=True)
torchaudio.save(tmp_wav.name, signal, 16000)
# Transcribe with Whisper
result = model.transcribe(tmp_wav.name)
transcript = result['text']
# Save transcript to file
with tempfile.NamedTemporaryFile(suffix=".txt", delete=False, mode="w") as f:
f.write(transcript)
transcript_file_path = f.name
return transcript, transcript_file_path
# Gradio Interface
app = gr.Interface(
fn=transcribe_audio,
inputs=gr.Audio(type="filepath", label="🎙️ Upload Meeting Audio"),
outputs=[
gr.Textbox(label="📝 Transcript", lines=10),
gr.File(label="⬇️ Download Transcript (.txt)")
],
title="🎧 Meeting Summarizer (STT Only)",
description="Upload your meeting audio and get a clean transcript you can read and download.",
theme="soft"
)
app.launch()
|