dhruvshettty commited on
Commit
c1b2725
1 Parent(s): d8fe938

Initial commit

Browse files
Files changed (2) hide show
  1. app.py +35 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pytube import YouTube
2
+ from transformers import pipeline
3
+ import gradio as gr
4
+ import os
5
+
6
+ model = pipeline(model="renesteeman/whisper-base-dutch-25")
7
+
8
+ def get_audio(url):
9
+ yt = YouTube(url)
10
+ video = yt.streams.filter(only_audio=True).first()
11
+ out_file=video.download(output_path=".")
12
+ base, ext = os.path.splitext(out_file)
13
+ new_file = base+'.mp3'
14
+ os.rename(out_file, new_file)
15
+ a = new_file
16
+ return a
17
+
18
+ def get_text(url):
19
+ # result = model.transcribe(get_audio(url))
20
+ # return result['text'].strip()
21
+ text = model(get_audio(url))["text"]
22
+ return text
23
+
24
+ # For Local usage
25
+ # print(get_text("https://www.youtube.com/shorts/KvgkcQMCq44"))
26
+
27
+ iface = gr.Interface(
28
+ fn=get_text,
29
+ inputs="text",
30
+ outputs="text",
31
+ title="Whisper Small Dutch",
32
+ description="Realtime demo for Dutch speech recognition using a fine-tuned Whisper small model.",
33
+ )
34
+
35
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ pytube