Skip to content

Commit

Permalink
refactor: remove old keys like __enable_audio and render settings bas…
Browse files Browse the repository at this point in the history
…ed on availability of the tts provider
  • Loading branch information
devxpy committed Feb 29, 2024
1 parent 6aea87a commit 9c9a0dc
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions recipes/VideoBots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9c9a0dc

Please sign in to comment.