Skip to content

Commit

Permalink
correct setting split
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Feb 11, 2024
1 parent 2d2312f commit 94fd36c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 32 deletions.
43 changes: 26 additions & 17 deletions daras_ai_v2/text_to_speech_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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="""
Expand Down Expand Up @@ -208,7 +217,7 @@ def text_to_speech_settings(page):
)

case TextToSpeechProviders.UBERDUCK.name:
with col2:
with col:
st.selectbox(
label="""
###### Voice name (Uberduck)
Expand All @@ -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
Expand Down
38 changes: 23 additions & 15 deletions recipes/VideoBots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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",
Expand All @@ -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(
Expand Down

0 comments on commit 94fd36c

Please sign in to comment.