kk90ujhun commited on
Commit
f5d6a53
·
1 Parent(s): 2c17a45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -9
app.py CHANGED
@@ -1,18 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from transformers import pipeline
 
2
  import gradio as gr
3
 
4
- pipe = pipeline(model="kk90ujhun/whisper-small-zh") # change to "your-username/the-name-you-picked"
 
 
 
 
 
 
 
 
5
 
6
- def transcribe(audio):
7
- text = pipe(audio)["text"]
8
- return text
9
 
10
  iface = gr.Interface(
11
- fn=transcribe,
12
- inputs=gr.Audio(source="microphone", type="filepath"),
13
- outputs="text",
14
- title="Whisper Small Chinese",
15
- description="Realtime demo for Chinese speech recognition using a fine-tuned Whisper small model.",
16
  )
17
 
18
  iface.launch()
 
1
+ # from transformers import pipeline
2
+ # import gradio as gr
3
+
4
+ # pipe = pipeline(model="kk90ujhun/whisper-small-zh") # change to "your-username/the-name-you-picked"
5
+
6
+ # def transcribe(audio):
7
+ # text = pipe(audio)["text"]
8
+ # return text
9
+
10
+ # iface = gr.Interface(
11
+ # fn=transcribe,
12
+ # inputs=gr.Audio(source="microphone", type="filepath"),
13
+ # outputs="text",
14
+ # title="Whisper Small Chinese",
15
+ # description="Realtime demo for Chinese speech recognition using a fine-tuned Whisper small model.",
16
+ # )
17
+
18
+ # iface.launch()
19
+
20
  from transformers import pipeline
21
+ from pytube import YouTube
22
  import gradio as gr
23
 
24
+ pipe = pipeline(model="kk90ujhun/whisper-small-zh")
25
+
26
+
27
+ def transcribe(url):
28
+ audio = YouTube(url).streams.filter(file_extension='mp4', only_audio=True).first().download()
29
+
30
+ text = pipe(audio, batch_size=512, truncation=True)["text"]
31
+
32
+ return text
33
 
 
 
 
34
 
35
  iface = gr.Interface(
36
+ fn=transcribe,
37
+ inputs=gr.Textbox(label="Enter a YouTube URL:"),
38
+ outputs="text",
39
+ title="Whisper Small Chinese",
40
+ description="Transcribe Chinese videos",
41
  )
42
 
43
  iface.launch()