From 9c9a0dc96f4a91720c40541f775b2abf35121f3b Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Thu, 29 Feb 2024 20:37:27 +0530 Subject: [PATCH] refactor: remove old keys like __enable_audio and render settings based on availability of the tts provider --- recipes/VideoBots.py | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/recipes/VideoBots.py b/recipes/VideoBots.py index adf7301b3..dabb6bf33 100644 --- a/recipes/VideoBots.py +++ b/recipes/VideoBots.py @@ -340,27 +340,20 @@ def render_form_v2(self): ) st.markdown("#### Capabilities") - if not "__enable_audio" in st.session_state: - st.session_state["__enable_audio"] = bool( - st.session_state.get("tts_provider") - ) - enable_audio = st.checkbox("##### 🗣️ Speak Responses", key="__enable_audio") - if not enable_audio: - st.session_state["tts_provider"] = None - enable_video = False - else: + if st.checkbox( + "##### 🗣️ Speak Responses", + value=bool(st.session_state.get("tts_provider")), + ): text_to_speech_provider_selector(self) st.write("---") - if not "__enable_video" in st.session_state: - st.session_state["__enable_video"] = bool( - st.session_state.get("input_face") - ) enable_video = st.checkbox( - "##### 🫦 Add Lipsync Video", key="__enable_video" + "##### 🫦 Add Lipsync Video", + value=bool(st.session_state.get("input_face")), ) - if not enable_video: - st.session_state["input_face"] = None else: + st.session_state["tts_provider"] = None + enable_video = False + if enable_video: st.file_uploader( """ ###### 👩‍🦰 Input Face @@ -370,11 +363,12 @@ def render_form_v2(self): key="input_face", ) st.write("---") + else: + st.session_state["input_face"] = None if st.checkbox( "##### 🔠 Translation", value=bool(st.session_state.get("user_language")), - key="__enable_translation", ): google_translate_language_selector( f"{field_desc(self.RequestModel, 'user_language')}", @@ -414,10 +408,11 @@ def render_settings(self): if tts_provider: text_to_speech_settings(self, tts_provider) - if st.session_state.get("__enable_video"): + input_face = st.session_state.get("__enable_video") + if input_face: lipsync_settings() - if st.session_state.get("__enable_translation"): + if st.session_state.get("user_language"): st.markdown("##### 🔠 Translation Settings") enable_glossary = st.checkbox( "📖 Add Glossary", @@ -445,9 +440,7 @@ def render_settings(self): st.session_state["input_glossary_document"] = None st.session_state["output_glossary_document"] = None - if st.session_state.get("documents") or st.session_state.get( - "__documents_files" - ): + if st.session_state.get("documents"): st.text_area( """ ##### 👩‍🏫 Document Search Results Instructions