Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the Whisper model for speech recognition | |
| pipe = pipeline("automatic-speech-recognition", model="openai/whisper-small") | |
| # Function to handle the speech recognition | |
| def transcribe_audio(audio): | |
| # Use the pipeline to transcribe the audio | |
| result = pipe(audio)["text"] | |
| return result | |
| # Create a Gradio interface for the audio input and transcription output | |
| interface = gr.Interface( | |
| fn=transcribe_audio, # Function that handles the transcription | |
| inputs=gr.Audio(type="filepath"), # Input as audio, no need for 'source' argument | |
| outputs="text", # Output as text | |
| title="Whisper Speech Recognition", | |
| description="Transcribe speech to text using OpenAI's Whisper model." | |
| ) | |
| # Launch the Gradio interface | |
| if __name__ == "__main__": | |
| interface.launch() | |