Gpagejr12 commited on
Commit
d84a346
·
verified ·
1 Parent(s): 2cae516

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -6,7 +6,13 @@ import os
6
  import numpy as np
7
  import base64
8
 
9
- genres = ["Pop", "Rock", "Jazz", "Electronic", "Hip-Hop", "Classical", "Lofi", "Chillpop"]
 
 
 
 
 
 
10
 
11
  @st.cache_resource()
12
  def load_model():
@@ -107,8 +113,8 @@ def main():
107
  audio_bytes = audio_file.read()
108
 
109
  # Play the full audio
110
- st.audio(audio_bytes, format='audio/wav')
111
- st.markdown(get_binary_file_downloader_html(audio_filepath, f'Audio_{idx}'), unsafe_allow_html=True)
112
 
113
 
114
  if __name__ == "__main__":
 
6
  import numpy as np
7
  import base64
8
 
9
+ # Add this function for downloading binary files
10
+ def get_binary_file_downloader_html(bin_file, file_label='File'):
11
+ with open(bin_file, 'rb') as f:
12
+ data = f.read()
13
+ bin_str = base64.b64encode(data).decode()
14
+ href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{file_label}">Download {file_label}</a>'
15
+ return href
16
 
17
  @st.cache_resource()
18
  def load_model():
 
113
  audio_bytes = audio_file.read()
114
 
115
  # Play the full audio
116
+ st.audio(audio_bytes, format='audio/wav')
117
+ st.markdown(get_binary_file_downloader_html(audio_filepath, f'Audio_{idx}'), unsafe_allow_html=True)
118
 
119
 
120
  if __name__ == "__main__":