Ibrahim Olanigan commited on
Commit
7dfdb5c
·
1 Parent(s): 86df489

Fixed transcript download

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -93,7 +93,8 @@ def display():
93
  with text_container:
94
  st.text_area(label=f"Youtube Transcript: {st.session_state[TITLE]}",
95
  height=200,
96
- value=st.session_state[TEXT])
 
97
 
98
  #Download Button section
99
  col1, col2 = st.columns(2)
@@ -101,10 +102,17 @@ def display():
101
  if AUDIO_EXISTS in st.session_state and st.session_state[AUDIO_EXISTS]:
102
  with open("audio.mp3", "rb") as f:
103
  data = f.read()
104
- st.download_button('Download MP3', data,"audio.mp3")
105
  with col2:
106
  if st.session_state[TRANSCRIPT_EXISTS]:
107
- st.download_button("Download Transcript",st.session_state[TEXT],"transcript.txt")
 
 
 
 
 
 
 
108
 
109
 
110
  def download():
 
93
  with text_container:
94
  st.text_area(label=f"Youtube Transcript: {st.session_state[TITLE]}",
95
  height=200,
96
+ value=st.session_state[TEXT],
97
+ )
98
 
99
  #Download Button section
100
  col1, col2 = st.columns(2)
 
102
  if AUDIO_EXISTS in st.session_state and st.session_state[AUDIO_EXISTS]:
103
  with open("audio.mp3", "rb") as f:
104
  data = f.read()
105
+ st.download_button('Download MP3', data,"audio.mp3", key="mp3")
106
  with col2:
107
  if st.session_state[TRANSCRIPT_EXISTS]:
108
+ if st.session_state[TEXT] == '':
109
+ with open(TRANSCRIPT, "rb") as f:
110
+ data = f.read()
111
+ # convert bytes to utf-8 string
112
+ data = data.decode("utf-8")
113
+ st.session_state[TEXT] = data
114
+
115
+ st.download_button("Download Transcript",st.session_state[TEXT],"transcript.txt", key="transcript")
116
 
117
 
118
  def download():