Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,13 @@ import os
|
|
6 |
import numpy as np
|
7 |
import base64
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
111 |
-
|
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__":
|