Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| import librosa | |
| # Initialize the ASR model | |
| asr_model = pipeline("automatic-speech-recognition", model="openai/whisper-small") | |
| def transcribe(file_path): | |
| # Load the audio file with librosa | |
| data, samplerate = librosa.load(file_path, sr=None) | |
| # Pass the audio data to the model for transcription without specifying sampling_rate | |
| transcription = asr_model(data) | |
| return transcription["text"] | |
| # Create the Gradio interface | |
| iface = gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.Audio(type="filepath", label="Record or Upload Audio"), | |
| outputs="text" | |
| ) | |
| # Launch the interface | |
| iface.launch() |