sensahin commited on
Commit
88c990d
1 Parent(s): c5dd44f

model selection added..

Browse files
Files changed (4) hide show
  1. .gitignore +3 -1
  2. app.py +23 -3
  3. convert.py +7 -6
  4. requirements.txt +1 -2
.gitignore CHANGED
@@ -128,4 +128,6 @@ dmypy.json
128
  # Pyre type checker
129
  .pyre/
130
  *.mp3
131
- *.mp4
 
 
 
128
  # Pyre type checker
129
  .pyre/
130
  *.mp3
131
+ *.mp4
132
+
133
+ .DS_Store
app.py CHANGED
@@ -20,8 +20,8 @@ def inference(audio):
20
  print(result.text)
21
  return result.text
22
 
23
- def inference2(url):
24
- return main(url)
25
 
26
 
27
  title="YouWhisper"
@@ -89,6 +89,23 @@ css = """
89
  font-weight: bold;
90
  font-size: 115%;
91
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  """
93
 
94
  block = gr.Blocks(css=css)
@@ -158,8 +175,11 @@ with block:
158
 
159
  # add another textbox to get url from user
160
  url = gr.Textbox(label="URL", show_label=False, placeholder="Enter Youtube URL")
 
 
161
  btn2 = gr.Button("Transcribe")
162
  text2 = gr.Textbox(show_label=False, placeholder="Transcription will appear here")
163
- btn2.click(inference2, inputs=[url], outputs=[text2])
 
164
 
165
  block.launch()
 
20
  print(result.text)
21
  return result.text
22
 
23
+ def inference2(url,mymodel):
24
+ return main(url,mymodel)
25
 
26
 
27
  title="YouWhisper"
 
89
  font-weight: bold;
90
  font-size: 115%;
91
  }
92
+ .gr-dropdown {
93
+ background-color: #fff;
94
+ border: 1px solid #e5e5e5;
95
+ border-radius: 4px;
96
+ color: #000;
97
+ cursor: pointer;
98
+ display: inline-block;
99
+ font-size: 1rem;
100
+ font-weight: 400;
101
+ line-height: 1.5;
102
+ margin-bottom: 0;
103
+ padding: .375rem .75rem;
104
+ transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
105
+ vertical-align: middle;
106
+ white-space: nowrap;
107
+ width: 100%;
108
+ }
109
  """
110
 
111
  block = gr.Blocks(css=css)
 
175
 
176
  # add another textbox to get url from user
177
  url = gr.Textbox(label="URL", show_label=False, placeholder="Enter Youtube URL")
178
+ # add dropdown to select the model
179
+ mymodel = gr.Dropdown(["tiny", "base", "small", "medium"])
180
  btn2 = gr.Button("Transcribe")
181
  text2 = gr.Textbox(show_label=False, placeholder="Transcription will appear here")
182
+ btn2.click(inference2, inputs=[url, mymodel], outputs=[text2])
183
+
184
 
185
  block.launch()
convert.py CHANGED
@@ -21,11 +21,13 @@ def AudiotoText(filename):
21
  sonuc = result["text"]
22
  return sonuc
23
 
24
- def main(url):
25
  print('''
26
  This tool will convert Youtube videos to mp3 files and then transcribe them to text using Whisper.
27
  ''')
28
 
 
 
29
  print("Downloading video... Please wait.")
30
  try:
31
  filename = download_video(url)
@@ -35,12 +37,12 @@ def main(url):
35
  return
36
  try:
37
  convert_to_mp3(filename)
38
- print("Converted video to mp3")
39
  except:
40
  print("Error converting video to mp3")
41
  return
42
  try:
43
- model = pywhisper.load_model("base")
44
  result = model.transcribe(filename[:-4] + ".mp3")
45
  print(result["text"])
46
  result = result["text"]
@@ -49,10 +51,9 @@ def main(url):
49
  print("Removed video and audio files")
50
  print("Done!")
51
  return result
52
- except:
53
- print("Error transcribing audio to text")
54
  return
55
 
56
-
57
  if __name__ == "__main__":
58
  main()
 
21
  sonuc = result["text"]
22
  return sonuc
23
 
24
+ def main(url,mymodel):
25
  print('''
26
  This tool will convert Youtube videos to mp3 files and then transcribe them to text using Whisper.
27
  ''')
28
 
29
+ print("URL: " + url)
30
+ print("Model: " + mymodel)
31
  print("Downloading video... Please wait.")
32
  try:
33
  filename = download_video(url)
 
37
  return
38
  try:
39
  convert_to_mp3(filename)
40
+ print("Video converted to mp3")
41
  except:
42
  print("Error converting video to mp3")
43
  return
44
  try:
45
+ model = pywhisper.load_model(mymodel)
46
  result = model.transcribe(filename[:-4] + ".mp3")
47
  print(result["text"])
48
  result = result["text"]
 
51
  print("Removed video and audio files")
52
  print("Done!")
53
  return result
54
+ except Exception as e:
55
+ print(e)
56
  return
57
 
 
58
  if __name__ == "__main__":
59
  main()
requirements.txt CHANGED
@@ -3,5 +3,4 @@ whisper
3
  pytube
4
  moviepy
5
  pywhisper
6
- flask
7
- static-ffmpeg
 
3
  pytube
4
  moviepy
5
  pywhisper
6
+ flask