File size: 804 Bytes
3b8ee99
 
 
 
 
 
4b4c24a
3b8ee99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0344ed
3b8ee99
 
 
 
 
 
 
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
from transformers import pipeline
import gradio as gr
import pytube
import os
import re

pipe = pipeline(model="WayneLinn/Lab2")  # change to "your-username/the-name-you-picked"

def transcribe(link):
    video=link
    data=pytube.YouTube(video)
    audio=data.streams.get_audio_only()
    audio.download()

    pattern=r".mp4$"
    content=os.listdir()
    for i in content:
        if re.search(pattern,i) is not None:
            video=i
    
    text = pipe(video)["text"]
    return text

iface = gr.Interface(
    fn=transcribe, 
    inputs=gr.Textbox(label="Youtube Link",placeholder="https://www.youtube.com/watch?v=scBCmwqxYmY"), 
    outputs=["text"],
    title="Whisper Base",
    description="Realtime demo for  speech recognition using a fine-tuned Whisper base model.",
)


iface.launch()