From 94fd36cfee29a67be19308688f5a537b1db02705 Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Sat, 10 Feb 2024 16:49:38 -0800 Subject: [PATCH] correct setting split --- .../text_to_speech_settings_widgets.py | 43 +++++++++++-------- recipes/VideoBots.py | 38 +++++++++------- 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/daras_ai_v2/text_to_speech_settings_widgets.py b/daras_ai_v2/text_to_speech_settings_widgets.py index 499b502d2..70c217b93 100644 --- a/daras_ai_v2/text_to_speech_settings_widgets.py +++ b/daras_ai_v2/text_to_speech_settings_widgets.py @@ -141,24 +141,33 @@ class TextToSpeechProviders(Enum): } -def text_to_speech_settings(page): - st.write( - """ - ##### 🗣️ Voice Settings - """ - ) - - col1, col2 = st.columns(2) - with col1: - tts_provider = enum_selector( - TextToSpeechProviders, - "###### Speech Provider", - key="tts_provider", +def text_to_speech_settings( + page, include_title=True, include_selector=True, include_settings=True +): + if include_title: + st.write( + """ + ##### 🗣️ Voice Settings + """ ) + col1, col2 = st.columns(2) + if include_selector: + with col1: + tts_provider = enum_selector( + TextToSpeechProviders, + "###### Speech Provider", + key="tts_provider", + ) + else: + tts_provider = st.session_state.get("tts_provider") + + if not include_settings: + return + col = col2 if include_selector else st.div() match tts_provider: case TextToSpeechProviders.BARK.name: - with col2: + with col: st.selectbox( label=""" ###### Bark History Prompt @@ -169,7 +178,7 @@ def text_to_speech_settings(page): ) case TextToSpeechProviders.GOOGLE_TTS.name: - with col2: + with col: voices = google_tts_voices() st.selectbox( label=""" @@ -208,7 +217,7 @@ def text_to_speech_settings(page): ) case TextToSpeechProviders.UBERDUCK.name: - with col2: + with col: st.selectbox( label=""" ###### Voice name (Uberduck) @@ -232,7 +241,7 @@ def text_to_speech_settings(page): ) case TextToSpeechProviders.ELEVEN_LABS.name: - with col2: + with col: if not st.session_state.get("elevenlabs_api_key"): st.session_state["elevenlabs_api_key"] = page.request.session.get( SESSION_ELEVENLABS_API_KEY diff --git a/recipes/VideoBots.py b/recipes/VideoBots.py index e4e74614d..727566611 100644 --- a/recipes/VideoBots.py +++ b/recipes/VideoBots.py @@ -346,6 +346,10 @@ def render_form_v2(self): st.session_state["tts_provider"] = None enable_video = False else: + text_to_speech_settings( + page=self, include_title=False, include_settings=False + ) + st.write("---") if not "__enable_video" in st.session_state: st.session_state["__enable_video"] = bool( st.session_state.get("input_face") @@ -355,12 +359,27 @@ def render_form_v2(self): ) if not enable_video: st.session_state["input_face"] = None + else: + st.file_uploader( + """ + ###### 👩‍🦰 Input Face + Upload a video/image that contains faces to use + *Recommended - mp4 / mov / png / jpg / gif* + """, + key="input_face", + ) + st.write("---") - st.checkbox( + 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')}", + key="user_language", + ) + st.write("---") if st.checkbox( "##### 🩻 Photo & Document Intelligence", @@ -383,24 +402,13 @@ def render_usage_guide(self): def render_settings(self): if st.session_state.get("__enable_audio"): - text_to_speech_settings(page=self) + text_to_speech_settings(page=self, include_selector=False) if st.session_state.get("__enable_video"): - st.file_uploader( - """ - ##### 👩‍🦰 Input Face - Upload a video/image that contains faces to use - *Recommended - mp4 / mov / png / jpg / gif* - """, - key="input_face", - ) lipsync_settings() if st.session_state.get("__enable_translation"): - google_translate_language_selector( - f"##### {field_title_desc(self.RequestModel, 'user_language')}", - key="user_language", - ) + st.markdown("##### 🔠 Translation Settings") enable_glossary = st.checkbox( "📖 Add Glossary", value=bool(