Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -475,32 +475,35 @@ def display_glossary_grid(roleplaying_glossary):
|
|
475 |
@st.cache_resource
|
476 |
def get_table_download_link(file_path):
|
477 |
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
|
|
|
|
|
|
504 |
|
505 |
|
506 |
@st.cache_resource
|
@@ -1503,7 +1506,7 @@ if filename is not None:
|
|
1503 |
|
1504 |
transcript=transcribe_canary(filename)
|
1505 |
result = search_arxiv(transcript)
|
1506 |
-
result2 = search_glossary(result)
|
1507 |
#st.markdown(result)
|
1508 |
#st.markdown
|
1509 |
|
|
|
475 |
@st.cache_resource
|
476 |
def get_table_download_link(file_path):
|
477 |
|
478 |
+
try:
|
479 |
+
#with open(file_path, 'r') as file:
|
480 |
+
#with open(file_path, 'r', encoding="unicode", errors="surrogateescape") as file:
|
481 |
+
with open(file_path, 'r', encoding='utf-8') as file:
|
482 |
+
data = file.read()
|
483 |
+
|
484 |
+
b64 = base64.b64encode(data.encode()).decode()
|
485 |
+
file_name = os.path.basename(file_path)
|
486 |
+
ext = os.path.splitext(file_name)[1] # get the file extension
|
487 |
+
if ext == '.txt':
|
488 |
+
mime_type = 'text/plain'
|
489 |
+
elif ext == '.py':
|
490 |
+
mime_type = 'text/plain'
|
491 |
+
elif ext == '.xlsx':
|
492 |
+
mime_type = 'text/plain'
|
493 |
+
elif ext == '.csv':
|
494 |
+
mime_type = 'text/plain'
|
495 |
+
elif ext == '.htm':
|
496 |
+
mime_type = 'text/html'
|
497 |
+
elif ext == '.md':
|
498 |
+
mime_type = 'text/markdown'
|
499 |
+
elif ext == '.wav':
|
500 |
+
mime_type = 'audio/wav'
|
501 |
+
else:
|
502 |
+
mime_type = 'application/octet-stream' # general binary data type
|
503 |
+
href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
|
504 |
+
return href
|
505 |
+
except:
|
506 |
+
return ''
|
507 |
|
508 |
|
509 |
@st.cache_resource
|
|
|
1506 |
|
1507 |
transcript=transcribe_canary(filename)
|
1508 |
result = search_arxiv(transcript)
|
1509 |
+
#result2 = search_glossary(result)
|
1510 |
#st.markdown(result)
|
1511 |
#st.markdown
|
1512 |
|