import gradio as gr | |
import os | |
from transformers import pipeline | |
# Load ASR pipeline | |
asr = pipeline(task="automatic-speech-recognition", | |
model="distil-whisper/distil-small.en") | |
# Define function | |
def transcribe(audio): | |
out = asr(audio) | |
return out['text'] # Extract transcribed text | |
# Create Gradio Interface | |
iface = gr.Interface(fn=transcribe, | |
inputs=gr.Audio(type="filepath"), # Expect an audio file path | |
outputs="text") | |
# Launch Interface | |
iface.launch(share=True, | |
server_port=int(os.environ.get('PORT1', 7860))) | |