File size: 1,299 Bytes
b7d40e6
 
 
 
 
 
d22a190
 
b7d40e6
 
 
 
 
d22a190
 
b7d40e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d22a190
b7d40e6
d22a190
 
b7d40e6
 
 
 
 
 
d22a190
 
 
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
44
45
46
47
48
49
import os
import gradio as gr
from transformers import pipeline
from pytube import YouTube


pipe = pipeline(model="Manbearpig01/whisper-small-hi") 
#https://www.youtube.com/watch?v=IagbSHyZ5iA


def yt(link):
    yt = YouTube(link)
    stream = yt.streams.filter(only_audio=True)[0]
    stream.download(filename="audio.mp4")
    text = pipe("audio.mp4")["text"]
    return text

def transcribe(audio):
    text = pipe(audio)["text"]
    return text

demo = gr.Blocks()


iface = gr.Interface(
    fn=transcribe, 
    inputs=gr.Audio(source="microphone", type="filepath"), 
    outputs="text",
    title="Whisper Small Swedish-Microphone",
    description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model. An audio for recognize.",
)

yt = gr.Interface(
    fn=yt,
    inputs=[gr.inputs.Textbox(lines=1, label="Youtube URL")],
    outputs=["text"],
    title="Whisper Small Swedish-Youtube",
    description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model. A Youtube URL for recognize. Suggest link1: https://www.youtube.com/watch?v=IagbSHyZ5iA link2:https://www.youtube.com/watch?v=gjvOMoDf4-4"


)

with demo:
    gr.TabbedInterface([iface, yt], ["Transcribe Audio", "Transcribe YouTube"])



demo.launch(enable_queue=True)