Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Feb 15, 2024
1 parent 94fd36c commit d9d3de1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 38 deletions.
2 changes: 1 addition & 1 deletion daras_ai_v2/lipsync_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def lipsync_settings():
st.write(
"""
##### ⌖ Face Padding
##### ⌖ Lipsync Face Padding
Adjust the detected face bounding box. Often leads to improved results.
Recommended to give at least 10 padding for the chin region.
"""
Expand Down
89 changes: 52 additions & 37 deletions daras_ai_v2/text_to_speech_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@


class TextToSpeechProviders(Enum):
GOOGLE_TTS = "Google Cloud Text-to-Speech"
GOOGLE_TTS = "Google Text-to-Speech"
ELEVEN_LABS = "Eleven Labs"
UBERDUCK = "uberduck.ai"
UBERDUCK = "Uberduck.ai"
BARK = "Bark (suno-ai)"


Expand Down Expand Up @@ -162,11 +162,12 @@ def text_to_speech_settings(
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:
if not include_settings:
return

with col:
st.selectbox(
label="""
Expand All @@ -178,19 +179,23 @@ def text_to_speech_settings(
)

case TextToSpeechProviders.GOOGLE_TTS.name:
with col:
voices = google_tts_voices()
st.selectbox(
label="""
###### Voice name (Google TTS)
""",
key="google_voice_name",
format_func=voices.__getitem__,
options=voices.keys(),
)
st.caption(
"*Please refer to the list of voice names [here](https://cloud.google.com/text-to-speech/docs/voices)*"
)
with col2:
if include_selector:
voices = google_tts_voices()
st.selectbox(
label="""
###### Voice name (Google TTS)
""",
key="google_voice_name",
format_func=voices.__getitem__,
options=voices.keys(),
)
st.caption(
"*Please refer to the list of voice names [here](https://cloud.google.com/text-to-speech/docs/voices)*"
)

if not include_settings:
return

col1, col2 = st.columns(2)
with col1:
Expand All @@ -217,18 +222,21 @@ def text_to_speech_settings(
)

case TextToSpeechProviders.UBERDUCK.name:
with col:
st.selectbox(
label="""
###### Voice name (Uberduck)
""",
key="uberduck_voice_name",
format_func=lambda option: f"{option}",
options=UBERDUCK_VOICES.keys(),
)
with col2:
if include_selector:
st.selectbox(
label="""
###### Voice name (Uberduck)
""",
key="uberduck_voice_name",
format_func=lambda option: f"{option}",
options=UBERDUCK_VOICES.keys(),
)

col1, col2 = st.columns(2)
with col1:
if not include_settings:
return

with col:
st.slider(
"""
###### Speaking rate
Expand All @@ -241,16 +249,31 @@ def text_to_speech_settings(
)

case TextToSpeechProviders.ELEVEN_LABS.name:
if include_selector:
with col2:
st.selectbox(
"""
###### Voice Name (ElevenLabs)
""",
key="elevenlabs_voice_name",
format_func=str,
options=ELEVEN_LABS_VOICES.keys(),
)

if not include_settings:
return

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
)

elevenlabs_use_custom_key = st.checkbox(
"Use custom API key + Voice ID",
"Use custom ElevenLabs API key + Voice ID",
value=bool(st.session_state.get("elevenlabs_api_key")),
)

if elevenlabs_use_custom_key:
st.session_state["elevenlabs_voice_name"] = None
elevenlabs_api_key = st.text_input(
Expand Down Expand Up @@ -308,14 +331,6 @@ def text_to_speech_settings(
st.session_state.update(
elevenlabs_api_key=None, elevenlabs_voice_id=None
)
st.selectbox(
"""
###### Voice Name (ElevenLabs)
""",
key="elevenlabs_voice_name",
format_func=str,
options=ELEVEN_LABS_VOICES.keys(),
)

page.request.session[SESSION_ELEVENLABS_API_KEY] = st.session_state.get(
"elevenlabs_api_key"
Expand Down

0 comments on commit d9d3de1

Please sign in to comment.