|
from transformers import pipeline |
|
import gradio as gr |
|
import os |
|
|
|
|
|
asr = pipeline(task="automatic-speech-recognition", |
|
model="distil-whisper/distil-small.en") |
|
|
|
|
|
def transcribe_long_form(filepath): |
|
if filepath is None: |
|
return "No audio file provided, please upload a file or record one." |
|
output = asr(filepath) |
|
return output['text'] |
|
|
|
|
|
with gr.Blocks() as demo: |
|
with gr.Tab("Transcribe Audio"): |
|
with gr.Row(): |
|
audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath") |
|
submit_button = gr.Button("Transcribe") |
|
transcription_output = gr.Textbox(label="Transcription", lines=3) |
|
|
|
submit_button.click( |
|
transcribe_long_form, |
|
inputs=[audio_input], |
|
outputs=[transcription_output] |
|
) |
|
|
|
|
|
demo.launch(share=True, server_port=int(os.environ.get('PORT1', 7860))) |
|
|