Spaces:
Runtime error
Runtime error
File size: 1,177 Bytes
704aa59 861d639 704aa59 e5fe152 704aa59 861d639 e3548cb 861d639 38fe3fe 506893a 38fe3fe 7a6e1cb 506893a 38fe3fe a72eede db29bad 704aa59 a72eede 704aa59 506893a db29bad 38fe3fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
from transformers import pipeline
import gradio as gr
from pytube import YouTube
import os
pipe = pipeline(model="afroanton/whisper-small-sv-SE") # change to "your-username/the-name-you-picked"
def transcribe(audio):
text = pipe(audio)["text"]
return text
def transcribeUrl(url):
yt = YouTube(str(url))
audio = yt.streams.filter(only_audio=True).first().download('yt_video')
text = pipe(audio)["text"]
return text
url_examples = [
"https://www.youtube.com/watch?v=UuDQBjPDbbA&ab_channel=Nyhetsmorgon"
]
url_demo = gr.Interface(
fn=transcribeUrl,
examples=url_examples,
inputs="text",
outputs="text",
title="Whisper Small Swedish",
description="Swedish speech and audio recognition using a fine-tuned Whipser small model",
)
voice_demo = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="filepath"),
outputs="text",
title="Whisper Small Swedish",
description="Swedish speech and audio recognition using a fine-tuned Whipser small model",
)
demo = gr.TabbedInterface([url_demo, voice_demo], ["video-to-text", "voice-to-text"])
if __name__ == "__main__":
demo.launch()
|