Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -106,10 +106,6 @@ if 'last_query' not in st.session_state:
|
|
106 |
if 'marquee_content' not in st.session_state:
|
107 |
st.session_state['marquee_content'] = "π Welcome to TalkingAIResearcher | π€ Your Research Assistant"
|
108 |
|
109 |
-
# New: default AutoRun to False (off)
|
110 |
-
if 'autorun' not in st.session_state:
|
111 |
-
st.session_state['autorun'] = False
|
112 |
-
|
113 |
# API Keys
|
114 |
openai_api_key = os.getenv('OPENAI_API_KEY', "")
|
115 |
anthropic_key = os.getenv('ANTHROPIC_API_KEY_3', "")
|
@@ -128,14 +124,7 @@ API_URL = os.getenv('API_URL')
|
|
128 |
FILE_EMOJIS = {
|
129 |
"md": "π",
|
130 |
"mp3": "π΅",
|
131 |
-
"wav": "π"
|
132 |
-
"pdf": "π",
|
133 |
-
"mp4": "π₯",
|
134 |
-
"csv": "π",
|
135 |
-
"xlsx": "π",
|
136 |
-
"html": "π",
|
137 |
-
"py": "π",
|
138 |
-
"txt": "π"
|
139 |
}
|
140 |
|
141 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
@@ -450,45 +439,35 @@ def display_papers_in_sidebar(papers):
|
|
450 |
st.markdown(f"**Summary:** {paper['summary'][:300]}...")
|
451 |
|
452 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
453 |
-
# 4. ZIP
|
454 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
455 |
|
456 |
-
def
|
457 |
"""
|
458 |
-
Zip up all
|
459 |
to avoid overly long base64 strings.
|
460 |
"""
|
461 |
-
|
462 |
-
|
463 |
-
"*.md", "*.pdf", "*.mp4", "*.mp3", "*.wav",
|
464 |
-
"*.csv", "*.xlsx", "*.html", "*.py", "*.txt"
|
465 |
-
]
|
466 |
-
all_files = []
|
467 |
-
for pat in file_patterns:
|
468 |
-
all_files.extend(glob.glob(pat))
|
469 |
-
all_files = list(set(all_files)) # unique
|
470 |
-
|
471 |
if not all_files:
|
472 |
return None
|
473 |
|
474 |
-
# Combine content for naming
|
475 |
all_content = []
|
476 |
for f in all_files:
|
477 |
-
if f.endswith(
|
478 |
-
with open(f,
|
479 |
-
all_content.append(
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
combined_content = " ".join(all_content)
|
488 |
info_terms = get_high_info_terms(combined_content, top_n=10)
|
489 |
|
490 |
timestamp = format_timestamp_prefix()
|
491 |
-
name_text = '-'.join(term for term in info_terms[:5])
|
492 |
short_zip_name = (timestamp + "_" + name_text)[:20] + ".zip"
|
493 |
|
494 |
with zipfile.ZipFile(short_zip_name, 'w') as z:
|
@@ -496,16 +475,6 @@ def create_zip_of_all_files():
|
|
496 |
z.write(f)
|
497 |
return short_zip_name
|
498 |
|
499 |
-
def delete_all_files():
|
500 |
-
"""Removes all recognized file types from the directory."""
|
501 |
-
file_patterns = [
|
502 |
-
"*.md", "*.pdf", "*.mp4", "*.mp3", "*.wav",
|
503 |
-
"*.csv", "*.xlsx", "*.html", "*.py", "*.txt"
|
504 |
-
]
|
505 |
-
for pat in file_patterns:
|
506 |
-
for f in glob.glob(pat):
|
507 |
-
os.remove(f)
|
508 |
-
|
509 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
510 |
# 5. MAIN LOGIC: AI LOOKUP & VOICE INPUT
|
511 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
@@ -514,6 +483,9 @@ def perform_ai_lookup(q, vocal_summary=True, extended_refs=False,
|
|
514 |
titles_summary=True, full_audio=False):
|
515 |
"""Main routine that uses Anthropic (Claude) + Gradio ArXiv RAG pipeline."""
|
516 |
start = time.time()
|
|
|
|
|
|
|
517 |
|
518 |
# --- 1) Claude API
|
519 |
client = anthropic.Anthropic(api_key=anthropic_key)
|
@@ -544,6 +516,7 @@ def perform_ai_lookup(q, vocal_summary=True, extended_refs=False,
|
|
544 |
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
545 |
api_name="/update_with_rag_md"
|
546 |
)[0]
|
|
|
547 |
r2 = client.predict(
|
548 |
q,
|
549 |
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
@@ -599,21 +572,17 @@ def process_voice_input(text):
|
|
599 |
|
600 |
def display_file_history_in_sidebar():
|
601 |
"""
|
602 |
-
Shows a history of each
|
603 |
order of modification time, with quick icons and optional download links.
|
604 |
"""
|
605 |
st.sidebar.markdown("---")
|
606 |
st.sidebar.markdown("### π File History")
|
607 |
|
608 |
-
#
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
all_files = []
|
614 |
-
for p in patterns:
|
615 |
-
all_files.extend(glob.glob(p))
|
616 |
-
all_files = list(set(all_files)) # unique
|
617 |
|
618 |
if not all_files:
|
619 |
st.sidebar.write("No files found.")
|
@@ -648,93 +617,103 @@ def display_file_history_in_sidebar():
|
|
648 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
649 |
|
650 |
def main():
|
651 |
-
|
652 |
-
Main Streamlit app.
|
653 |
-
Now includes:
|
654 |
-
1) Voice & AutoRun at the top of the sidebar,
|
655 |
-
2) File Tools (Delete All / Zip All) in the sidebar,
|
656 |
-
3) A new 'π€ Upload' tab,
|
657 |
-
4) Everything else from your original code snippet.
|
658 |
-
"""
|
659 |
-
|
660 |
-
# -- 1) Voice & AutoRun at top of sidebar --
|
661 |
-
st.sidebar.title("Global Settings")
|
662 |
-
selected_voice = st.sidebar.selectbox(
|
663 |
-
"TTS Voice",
|
664 |
-
options=EDGE_TTS_VOICES,
|
665 |
-
index=EDGE_TTS_VOICES.index(st.session_state['tts_voice'])
|
666 |
-
)
|
667 |
-
# Autorun defaults to off (False)
|
668 |
-
st.session_state.autorun = st.sidebar.checkbox("AutoRun", value=st.session_state.autorun)
|
669 |
-
|
670 |
-
# Audio format
|
671 |
-
audio_format = st.sidebar.radio("Audio Format", ["MP3","WAV"], index=0)
|
672 |
-
if selected_voice != st.session_state['tts_voice']:
|
673 |
-
st.session_state['tts_voice'] = selected_voice
|
674 |
-
st.experimental_rerun()
|
675 |
-
if audio_format.lower() != st.session_state['audio_format']:
|
676 |
-
st.session_state['audio_format'] = audio_format.lower()
|
677 |
-
st.experimental_rerun()
|
678 |
-
|
679 |
-
# -- 2) File Tools: Delete All / Zip All
|
680 |
-
st.sidebar.markdown("---")
|
681 |
-
st.sidebar.markdown("### π File Tools")
|
682 |
-
col_del, col_zip = st.sidebar.columns(2)
|
683 |
-
with col_del:
|
684 |
-
if st.button("π Delete All"):
|
685 |
-
delete_all_files()
|
686 |
-
st.sidebar.success("All recognized files removed!")
|
687 |
-
st.experimental_rerun()
|
688 |
-
with col_zip:
|
689 |
-
if st.button("π¦ Zip All"):
|
690 |
-
zip_name = create_zip_of_all_files()
|
691 |
-
if zip_name:
|
692 |
-
st.sidebar.markdown(get_download_link(zip_name, "zip"), unsafe_allow_html=True)
|
693 |
-
|
694 |
-
# -- 3) Marquee Settings
|
695 |
update_marquee_settings_ui()
|
696 |
marquee_settings = get_marquee_settings()
|
697 |
|
698 |
-
#
|
699 |
-
display_file_history_in_sidebar()
|
700 |
-
|
701 |
-
# -- 5) Display marquee
|
702 |
display_marquee(st.session_state['marquee_content'],
|
703 |
{**marquee_settings, "font-size": "28px", "lineHeight": "50px"},
|
704 |
key_suffix="welcome")
|
705 |
|
706 |
-
#
|
707 |
-
tab_main = st.radio(
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
712 |
|
713 |
-
#
|
714 |
-
|
715 |
-
|
716 |
-
accepted_types = [
|
717 |
-
# We'll accept basically everything (None in file_uploader),
|
718 |
-
# but let's specify for clarity:
|
719 |
-
"text/plain", "text/markdown", "audio/mpeg", "audio/wav",
|
720 |
-
"image/png", "image/jpeg", "video/mp4", "application/pdf",
|
721 |
-
"application/vnd.ms-excel",
|
722 |
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
723 |
-
"text/html", "application/octet-stream",
|
724 |
-
]
|
725 |
-
uploaded = st.file_uploader("Select files to upload:",
|
726 |
-
accept_multiple_files=True,
|
727 |
-
type=None)
|
728 |
-
if uploaded:
|
729 |
-
for uf in uploaded:
|
730 |
-
with open(uf.name, "wb") as outfile:
|
731 |
-
outfile.write(uf.read())
|
732 |
-
st.success("Uploaded!")
|
733 |
-
st.session_state.should_rerun = True
|
734 |
-
|
735 |
-
# 6b) Voice Tab
|
736 |
elif tab_main == "π€ Voice":
|
737 |
st.subheader("π€ Voice Input")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
738 |
user_text = st.text_area("π¬ Message:", height=100)
|
739 |
user_text = user_text.strip().replace('\n', ' ')
|
740 |
|
@@ -746,10 +725,16 @@ def main():
|
|
746 |
st.write("**You:**", c["user"])
|
747 |
st.write("**Response:**", c["claude"])
|
748 |
|
749 |
-
#
|
|
|
|
|
750 |
elif tab_main == "πΈ Media":
|
751 |
st.header("πΈ Media Gallery")
|
|
|
|
|
752 |
tabs = st.tabs(["π΅ Audio", "πΌ Images", "π₯ Video"])
|
|
|
|
|
753 |
with tabs[0]:
|
754 |
st.subheader("π΅ Audio Files")
|
755 |
audio_files = glob.glob("*.mp3") + glob.glob("*.wav")
|
@@ -762,6 +747,8 @@ def main():
|
|
762 |
st.markdown(dl_link, unsafe_allow_html=True)
|
763 |
else:
|
764 |
st.write("No audio files found.")
|
|
|
|
|
765 |
with tabs[1]:
|
766 |
st.subheader("πΌ Image Files")
|
767 |
imgs = glob.glob("*.png") + glob.glob("*.jpg") + glob.glob("*.jpeg")
|
@@ -773,6 +760,8 @@ def main():
|
|
773 |
st.image(Image.open(f), use_container_width=True)
|
774 |
else:
|
775 |
st.write("No images found.")
|
|
|
|
|
776 |
with tabs[2]:
|
777 |
st.subheader("π₯ Video Files")
|
778 |
vids = glob.glob("*.mp4") + glob.glob("*.mov") + glob.glob("*.avi")
|
@@ -783,45 +772,30 @@ def main():
|
|
783 |
else:
|
784 |
st.write("No videos found.")
|
785 |
|
786 |
-
#
|
787 |
-
|
788 |
-
|
789 |
-
q = st.text_input("π Query:", key="arxiv_query")
|
790 |
-
|
791 |
-
st.markdown("### π Options")
|
792 |
-
st.write("(AutoRun is in the sidebar.)")
|
793 |
-
extended_refs = st.checkbox("πLongRefs", value=False, key="option_extended_refs")
|
794 |
-
titles_summary = st.checkbox("πTitlesOnly", value=True, key="option_titles_summary")
|
795 |
-
full_audio = st.checkbox("πFullAudio", value=False, key="option_full_audio")
|
796 |
-
full_transcript = st.checkbox("π§ΎFullTranscript", value=False, key="option_full_transcript")
|
797 |
-
|
798 |
-
if q and st.button("πRun"):
|
799 |
-
st.session_state.last_query = q
|
800 |
-
result = perform_ai_lookup(q,
|
801 |
-
extended_refs=extended_refs,
|
802 |
-
titles_summary=titles_summary,
|
803 |
-
full_audio=full_audio)
|
804 |
-
if full_transcript:
|
805 |
-
create_file(q, result, "md")
|
806 |
-
|
807 |
-
# If AutoRun is ON and user typed something
|
808 |
-
if st.session_state.autorun and q:
|
809 |
-
st.session_state.last_query = q
|
810 |
-
result = perform_ai_lookup(q,
|
811 |
-
extended_refs=extended_refs,
|
812 |
-
titles_summary=titles_summary,
|
813 |
-
full_audio=full_audio)
|
814 |
-
if full_transcript:
|
815 |
-
create_file(q, result, "md")
|
816 |
-
|
817 |
-
# 6e) Editor Tab
|
818 |
elif tab_main == "π Editor":
|
819 |
st.write("Select or create a file to edit. (Currently minimal demo)")
|
820 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
821 |
# Rerun if needed
|
822 |
if st.session_state.should_rerun:
|
823 |
st.session_state.should_rerun = False
|
824 |
-
st.
|
825 |
|
826 |
if __name__ == "__main__":
|
827 |
main()
|
|
|
106 |
if 'marquee_content' not in st.session_state:
|
107 |
st.session_state['marquee_content'] = "π Welcome to TalkingAIResearcher | π€ Your Research Assistant"
|
108 |
|
|
|
|
|
|
|
|
|
109 |
# API Keys
|
110 |
openai_api_key = os.getenv('OPENAI_API_KEY', "")
|
111 |
anthropic_key = os.getenv('ANTHROPIC_API_KEY_3', "")
|
|
|
124 |
FILE_EMOJIS = {
|
125 |
"md": "π",
|
126 |
"mp3": "π΅",
|
127 |
+
"wav": "π"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
}
|
129 |
|
130 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
439 |
st.markdown(f"**Summary:** {paper['summary'][:300]}...")
|
440 |
|
441 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
442 |
+
# 4. ZIP FUNCTION
|
443 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
444 |
|
445 |
+
def create_zip_of_files(md_files, mp3_files, wav_files, input_question):
|
446 |
"""
|
447 |
+
Zip up all relevant files, limiting the final zip name to ~20 chars
|
448 |
to avoid overly long base64 strings.
|
449 |
"""
|
450 |
+
md_files = [f for f in md_files if os.path.basename(f).lower() != 'readme.md']
|
451 |
+
all_files = md_files + mp3_files + wav_files
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
if not all_files:
|
453 |
return None
|
454 |
|
|
|
455 |
all_content = []
|
456 |
for f in all_files:
|
457 |
+
if f.endswith('.md'):
|
458 |
+
with open(f, 'r', encoding='utf-8') as file:
|
459 |
+
all_content.append(file.read())
|
460 |
+
elif f.endswith('.mp3') or f.endswith('.wav'):
|
461 |
+
basename = os.path.splitext(os.path.basename(f))[0]
|
462 |
+
words = basename.replace('_', ' ')
|
463 |
+
all_content.append(words)
|
464 |
+
|
465 |
+
all_content.append(input_question)
|
|
|
466 |
combined_content = " ".join(all_content)
|
467 |
info_terms = get_high_info_terms(combined_content, top_n=10)
|
468 |
|
469 |
timestamp = format_timestamp_prefix()
|
470 |
+
name_text = '-'.join(term for term in info_terms[:5])
|
471 |
short_zip_name = (timestamp + "_" + name_text)[:20] + ".zip"
|
472 |
|
473 |
with zipfile.ZipFile(short_zip_name, 'w') as z:
|
|
|
475 |
z.write(f)
|
476 |
return short_zip_name
|
477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
479 |
# 5. MAIN LOGIC: AI LOOKUP & VOICE INPUT
|
480 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
483 |
titles_summary=True, full_audio=False):
|
484 |
"""Main routine that uses Anthropic (Claude) + Gradio ArXiv RAG pipeline."""
|
485 |
start = time.time()
|
486 |
+
ai_constitution = """
|
487 |
+
You are a talented AI coder and songwriter...
|
488 |
+
"""
|
489 |
|
490 |
# --- 1) Claude API
|
491 |
client = anthropic.Anthropic(api_key=anthropic_key)
|
|
|
516 |
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
517 |
api_name="/update_with_rag_md"
|
518 |
)[0]
|
519 |
+
|
520 |
r2 = client.predict(
|
521 |
q,
|
522 |
"mistralai/Mixtral-8x7B-Instruct-v0.1",
|
|
|
572 |
|
573 |
def display_file_history_in_sidebar():
|
574 |
"""
|
575 |
+
Shows a history of each local .md, .mp3, .wav file in descending
|
576 |
order of modification time, with quick icons and optional download links.
|
577 |
"""
|
578 |
st.sidebar.markdown("---")
|
579 |
st.sidebar.markdown("### π File History")
|
580 |
|
581 |
+
# Gather all files
|
582 |
+
md_files = glob.glob("*.md")
|
583 |
+
mp3_files = glob.glob("*.mp3")
|
584 |
+
wav_files = glob.glob("*.wav")
|
585 |
+
all_files = md_files + mp3_files + wav_files
|
|
|
|
|
|
|
|
|
586 |
|
587 |
if not all_files:
|
588 |
st.sidebar.write("No files found.")
|
|
|
617 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
618 |
|
619 |
def main():
|
620 |
+
# 1) Setup marquee UI in the sidebar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
update_marquee_settings_ui()
|
622 |
marquee_settings = get_marquee_settings()
|
623 |
|
624 |
+
# 2) Display the marquee welcome
|
|
|
|
|
|
|
625 |
display_marquee(st.session_state['marquee_content'],
|
626 |
{**marquee_settings, "font-size": "28px", "lineHeight": "50px"},
|
627 |
key_suffix="welcome")
|
628 |
|
629 |
+
# 3) Main action tabs
|
630 |
+
tab_main = st.radio("Action:", ["π€ Voice", "πΈ Media", "π ArXiv", "π Editor"],
|
631 |
+
horizontal=True)
|
632 |
+
|
633 |
+
# Example custom component usage
|
634 |
+
mycomponent = components.declare_component("mycomponent", path="mycomponent")
|
635 |
+
val = mycomponent(my_input_value="Hello")
|
636 |
+
|
637 |
+
if val:
|
638 |
+
val_stripped = val.replace('\\n', ' ')
|
639 |
+
edited_input = st.text_area("βοΈ Edit Input:", value=val_stripped, height=100)
|
640 |
+
run_option = st.selectbox("Model:", ["Arxiv"])
|
641 |
+
col1, col2 = st.columns(2)
|
642 |
+
with col1:
|
643 |
+
autorun = st.checkbox("β AutoRun", value=True)
|
644 |
+
with col2:
|
645 |
+
full_audio = st.checkbox("πFullAudio", value=False)
|
646 |
+
|
647 |
+
input_changed = (val != st.session_state.old_val)
|
648 |
+
|
649 |
+
if autorun and input_changed:
|
650 |
+
st.session_state.old_val = val
|
651 |
+
st.session_state.last_query = edited_input
|
652 |
+
perform_ai_lookup(edited_input,
|
653 |
+
vocal_summary=True,
|
654 |
+
extended_refs=False,
|
655 |
+
titles_summary=True,
|
656 |
+
full_audio=full_audio)
|
657 |
+
else:
|
658 |
+
if st.button("βΆ Run"):
|
659 |
+
st.session_state.old_val = val
|
660 |
+
st.session_state.last_query = edited_input
|
661 |
+
perform_ai_lookup(edited_input,
|
662 |
+
vocal_summary=True,
|
663 |
+
extended_refs=False,
|
664 |
+
titles_summary=True,
|
665 |
+
full_audio=full_audio)
|
666 |
+
|
667 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
668 |
+
# TAB: ArXiv
|
669 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
670 |
+
if tab_main == "π ArXiv":
|
671 |
+
st.subheader("π Query ArXiv")
|
672 |
+
q = st.text_input("π Query:", key="arxiv_query")
|
673 |
+
|
674 |
+
st.markdown("### π Options")
|
675 |
+
vocal_summary = st.checkbox("πShortAudio", value=True, key="option_vocal_summary")
|
676 |
+
extended_refs = st.checkbox("πLongRefs", value=False, key="option_extended_refs")
|
677 |
+
titles_summary = st.checkbox("πTitlesOnly", value=True, key="option_titles_summary")
|
678 |
+
full_audio = st.checkbox("πFullAudio", value=False, key="option_full_audio")
|
679 |
+
full_transcript = st.checkbox("π§ΎFullTranscript", value=False, key="option_full_transcript")
|
680 |
+
|
681 |
+
if q and st.button("πRun"):
|
682 |
+
st.session_state.last_query = q
|
683 |
+
result = perform_ai_lookup(q, vocal_summary=vocal_summary, extended_refs=extended_refs,
|
684 |
+
titles_summary=titles_summary, full_audio=full_audio)
|
685 |
+
if full_transcript:
|
686 |
+
create_file(q, result, "md")
|
687 |
|
688 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
689 |
+
# TAB: Voice
|
690 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
691 |
elif tab_main == "π€ Voice":
|
692 |
st.subheader("π€ Voice Input")
|
693 |
+
|
694 |
+
st.markdown("### π€ Voice Settings")
|
695 |
+
selected_voice = st.selectbox(
|
696 |
+
"Select TTS Voice:",
|
697 |
+
options=EDGE_TTS_VOICES,
|
698 |
+
index=EDGE_TTS_VOICES.index(st.session_state['tts_voice'])
|
699 |
+
)
|
700 |
+
|
701 |
+
st.markdown("### π Audio Format")
|
702 |
+
selected_format = st.radio(
|
703 |
+
"Choose Audio Format:",
|
704 |
+
options=["MP3", "WAV"],
|
705 |
+
index=0
|
706 |
+
)
|
707 |
+
|
708 |
+
# Update session state if voice/format changes
|
709 |
+
if selected_voice != st.session_state['tts_voice']:
|
710 |
+
st.session_state['tts_voice'] = selected_voice
|
711 |
+
st.rerun()
|
712 |
+
if selected_format.lower() != st.session_state['audio_format']:
|
713 |
+
st.session_state['audio_format'] = selected_format.lower()
|
714 |
+
st.rerun()
|
715 |
+
|
716 |
+
# Input text
|
717 |
user_text = st.text_area("π¬ Message:", height=100)
|
718 |
user_text = user_text.strip().replace('\n', ' ')
|
719 |
|
|
|
725 |
st.write("**You:**", c["user"])
|
726 |
st.write("**Response:**", c["claude"])
|
727 |
|
728 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
729 |
+
# TAB: Media
|
730 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
731 |
elif tab_main == "πΈ Media":
|
732 |
st.header("πΈ Media Gallery")
|
733 |
+
|
734 |
+
# By default, show audio first
|
735 |
tabs = st.tabs(["π΅ Audio", "πΌ Images", "π₯ Video"])
|
736 |
+
|
737 |
+
# AUDIO sub-tab
|
738 |
with tabs[0]:
|
739 |
st.subheader("π΅ Audio Files")
|
740 |
audio_files = glob.glob("*.mp3") + glob.glob("*.wav")
|
|
|
747 |
st.markdown(dl_link, unsafe_allow_html=True)
|
748 |
else:
|
749 |
st.write("No audio files found.")
|
750 |
+
|
751 |
+
# IMAGES sub-tab
|
752 |
with tabs[1]:
|
753 |
st.subheader("πΌ Image Files")
|
754 |
imgs = glob.glob("*.png") + glob.glob("*.jpg") + glob.glob("*.jpeg")
|
|
|
760 |
st.image(Image.open(f), use_container_width=True)
|
761 |
else:
|
762 |
st.write("No images found.")
|
763 |
+
|
764 |
+
# VIDEO sub-tab
|
765 |
with tabs[2]:
|
766 |
st.subheader("π₯ Video Files")
|
767 |
vids = glob.glob("*.mp4") + glob.glob("*.mov") + glob.glob("*.avi")
|
|
|
772 |
else:
|
773 |
st.write("No videos found.")
|
774 |
|
775 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
776 |
+
# TAB: Editor
|
777 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
778 |
elif tab_main == "π Editor":
|
779 |
st.write("Select or create a file to edit. (Currently minimal demo)")
|
780 |
|
781 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
782 |
+
# SIDEBAR: FILE HISTORY
|
783 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
784 |
+
display_file_history_in_sidebar()
|
785 |
+
|
786 |
+
# Some light CSS styling
|
787 |
+
st.markdown("""
|
788 |
+
<style>
|
789 |
+
.main { background: linear-gradient(to right, #1a1a1a, #2d2d2d); color: #fff; }
|
790 |
+
.stMarkdown { font-family: 'Helvetica Neue', sans-serif; }
|
791 |
+
.stButton>button { margin-right: 0.5rem; }
|
792 |
+
</style>
|
793 |
+
""", unsafe_allow_html=True)
|
794 |
+
|
795 |
# Rerun if needed
|
796 |
if st.session_state.should_rerun:
|
797 |
st.session_state.should_rerun = False
|
798 |
+
st.rerun()
|
799 |
|
800 |
if __name__ == "__main__":
|
801 |
main()
|