Spaces:
Build error
Build error
from transformers import pipeline | |
import gradio as gr | |
from pytube import YouTube | |
import os | |
pipe = pipeline(model="CsanadT/whisper_small_sv") | |
def transcribe_live(audio): | |
text = pipe(audio)["text"] | |
return text | |
def transcribe_url(url): | |
youtube = YouTube(str(url)) | |
audio = youtube.streams.filter(only_audio=True).first().download('yt_video') | |
text = pipe(audio)["text"] | |
return text | |
def transcribe_file(audio): | |
rate, y = audio | |
text = pipe(y)["text"] | |
return text | |
url_demo = gr.Interface( | |
fn = transcribe_url, | |
inputs = "text", | |
outputs = "text", | |
title = "Swedish Whisper", | |
description = "Fine-tuned Whisper model for swedish audio transcription", | |
) | |
voice_demo = gr.Interface( | |
fn=transcribe_live, | |
inputs=gr.Audio(source="microphone", type="filepath"), | |
outputs="text", | |
title="Whisper Swedish", | |
description="Fine-tuned Whisper model for swedish audio transcription", | |
) | |
file_demo = gr.Interface( | |
fn = transcribe_file, | |
inputs=gr.Audio(file_count="single"), | |
outputs="text", | |
title="Swedish Whisper", | |
description="Fine-tuned Whisper model for swedish audio transcription", | |
) | |
demo = gr.TabbedInterface([url_demo, voice_demo, file_demo], ["YouTube video transciption", "Live audio to Text", "Transcribe a file"]) | |
demo.launch() |