WayneLinn commited on
Commit
3b8ee99
1 Parent(s): e69c67d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +33 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+ import pytube
4
+ import os
5
+ import re
6
+
7
+ pipe = pipeline(model="Yuyang2022/yue") # change to "your-username/the-name-you-picked"
8
+
9
+ def transcribe(link):
10
+ video=link
11
+ data=pytube.YouTube(video)
12
+ audio=data.streams.get_audio_only()
13
+ audio.download()
14
+
15
+ pattern=r".mp4$"
16
+ content=os.listdir()
17
+ for i in content:
18
+ if re.search(pattern,i) is not None:
19
+ video=i
20
+
21
+ text = pipe(video)["text"]
22
+ return text
23
+
24
+ iface = gr.Interface(
25
+ fn=transcribe,
26
+ inputs=gr.Textbox(label="Youtube Link",placeholder="Youtube Link"),
27
+ outputs=["text"],
28
+ title="Whisper Base",
29
+ description="Realtime demo for speech recognition using a fine-tuned Whisper base model.",
30
+ )
31
+
32
+
33
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch
2
+ git+https://github.com/huggingface/transformers
3
+ gradio
4
+ pytube
5
+ ffmpeg-python