File size: 747 Bytes
2c17a45
 
f3ac8fd
2c17a45
f3ac8fd
f5d6a53
 
f3ac8fd
 
 
 
 
 
 
 
2c17a45
 
f3ac8fd
 
 
 
 
 
 
 
2c17a45
 
f3ac8fd
2c17a45
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
from transformers import pipeline
import gradio as gr
import pytube

pipe = pipeline(model="kk90ujhun/whisper-small-zh") 


def transcribe(my_url,audio):
  if my_url:
    my_audio = pytube.YouTube(my_url).streams.filter(subtype='mp4').first().download()
    text = pipe(my_audio)["text"]
    return text
  else:
    text = pipe(audio)["text"]
    return text

iface = gr.Interface(
    fn=transcribe, 
    inputs=[
        gr.Textbox(label="Enter your YouTube URL:"),
        gr.Audio(label="Speak to your microphone",source="microphone", type="filepath"),
        ], #
    outputs="text",
    title="Whisper Small Chinese",
    description="Realtime demo for Chinese speech recognition using a fine-tuned Whisper small model.",
)


iface.launch()