File size: 1,362 Bytes
77f334e
 
 
 
 
 
306c96d
 
 
 
 
77f334e
306c96d
 
 
b28a0c9
 
 
 
 
 
 
77f334e
 
 
306c96d
 
fbeec50
 
306c96d
 
fbeec50
 
b28a0c9
 
 
 
 
 
 
 
 
 
 
 
306c96d
 
 
 
 
 
 
 
 
fbeec50
 
 
b28a0c9
c41dac2
306c96d
b28a0c9
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
50
51
52
53
54
55
56
57
58
59
60
61
import gradio as gr
from transformers import pipeline
from pytube import YouTube

pipe = pipeline(model="irena/whisper-small-sv-SE")

def transcribe_video(url):  
  yt=YouTube(url).streams.filter(only_audio=True).all()
  audio=yt[0].download()
  text = pipe(audio)["text"]
  return text

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







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

file = gr.Interface(
    fn=transcribe_file,
    inputs=[
        gr.inputs.Audio(source="upload", type="filepath", optional=True),
    ],
    outputs="text",
    title="Whisper Small Swedish",
    description=(
        "Transcribe swedish audios"
    )
    
)

video = gr.Interface(
	fn=transcribe_video,
	inputs=gr.Textbox(label="Enter a YouTube URL:"),
	outputs="text",
	title="Whisper Small Swedish",
	description="Transcribe swedish videos from YouTube",
)




demo = gr.TabbedInterface([audio, file, video], ["transcribe from microphone", "transcribe from local audios", "transcribe from youtube url"])

if __name__ == "__main__":
    demo.launch()