Spaces:
Running
Running
| import gradio as gr | |
| from faster_whisper import WhisperModel | |
| # Load the model (adjust as needed: tiny, base, small, etc.) | |
| model = WhisperModel("base", compute_type="int8") # Optimized for CPU | |
| # Transcription function | |
| def transcribe(audio_file): | |
| if audio_file is None: | |
| return "No file provided." | |
| # Run transcription | |
| segments, _ = model.transcribe(audio_file) | |
| transcript = " ".join([segment.text for segment in segments]) | |
| return transcript | |
| # Gradio Interface | |
| iface = gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.File(type="filepath", label="Upload Audio (MP3, WAV, FLAC, etc.)"), | |
| outputs=gr.Textbox(label="Transcript"), | |
| title="Whisper Transcriber (Multi-Format)", | |
| description="Upload an audio file in any format (MP3, WAV, FLAC, etc.) to transcribe using Faster-Whisper." | |
| ) | |
| # Launch the app | |
| iface.launch() | |