Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import whisper | |
| import os | |
| # Load the Whisper model | |
| model = whisper.load_model("base") | |
| def transcribe_audio(audio_file): | |
| # Transcribe the audio | |
| result = model.transcribe(audio_file.name) | |
| # Get the base name of the file (without extension) for the output file | |
| output_filename = os.path.splitext(os.path.basename(audio_file.name))[0] + ".txt" | |
| # Save the transcript to a text file with the same name as the input file | |
| with open(output_filename, "w") as text_file: | |
| text_file.write(result["text"]) | |
| return result["text"], output_filename | |
| # Create Gradio interface | |
| iface = gr.Interface( | |
| fn=transcribe_audio, | |
| inputs=gr.File(label="Upload Audio File"), | |
| outputs=[ | |
| gr.Textbox(label="Transcription"), | |
| gr.File(label="Download Transcript") | |
| ], | |
| title="Audio Transcription Tool", | |
| description="Upload an audio file (WAV, MP3, etc.) to get its transcription. The transcript will be displayed and available for download." | |
| ) | |
| # Launch the interface | |
| iface.launch() |