Spaces:
Sleeping
Sleeping
| 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() | |