JoshMe1 commited on
Commit
5d96714
·
1 Parent(s): ae4618e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import whisper
3
  from pytube import YouTube
 
4
 
5
  def get_audio(url):
6
  yt = YouTube(url)
@@ -40,6 +41,15 @@ def save_srt(transcript):
40
  f.write(transcript)
41
  return True
42
 
 
 
 
 
 
 
 
 
 
43
  langs = ["None"] + sorted(list(whisper.tokenizer.LANGUAGES.values()))
44
  model_size = list(whisper._MODELS.keys())
45
 
@@ -56,15 +66,7 @@ if st.button("Transcribe"):
56
  st.text_area("Transcription of the video", transcript)
57
  if format == ".srt":
58
  save_srt(transcript)
59
- if st.button("Download Transcript"):
60
- file_ = open("transcript.srt", "rb")
61
- contents = file_.read()
62
- file_.close()
63
- st.download_button(
64
- label="Download Transcript",
65
- data=contents,
66
- file_name="done.srt",
67
- mime="text/srt"
68
- )
69
-
70
 
 
 
 
1
  import streamlit as st
2
  import whisper
3
  from pytube import YouTube
4
+ import os
5
 
6
  def get_audio(url):
7
  yt = YouTube(url)
 
41
  f.write(transcript)
42
  return True
43
 
44
+ def download_srt(transcript):
45
+ with open("done.txt", "w") as f:
46
+ f.write(transcript)
47
+ with open("done.txt", "r") as f:
48
+ srt = format_to_srt(f.read())
49
+ with open("transcript.srt", "w") as f:
50
+ f.write(srt)
51
+ return st.download_button(label="Download Transcript (.srt)", data="transcript.srt")
52
+
53
  langs = ["None"] + sorted(list(whisper.tokenizer.LANGUAGES.values()))
54
  model_size = list(whisper._MODELS.keys())
55
 
 
66
  st.text_area("Transcription of the video", transcript)
67
  if format == ".srt":
68
  save_srt(transcript)
69
+ download_srt(transcript)
 
 
 
 
 
 
 
 
 
 
70
 
71
+ if os.path.exists("done.txt"):
72
+ os.remove("done.txt")