Skip to content

Commit

Permalink
Merge pull request #86 from daviirodrig/voice-settings
Browse files Browse the repository at this point in the history
update voice settings and option to delete voice
  • Loading branch information
daviirodrig authored Feb 22, 2024

Verified

This commit was signed with the committer’s verified signature.
jrfnl Juliette
2 parents c1eac76 + 8cc85e8 commit bd7ffc4
Showing 4 changed files with 75 additions and 3 deletions.
9 changes: 7 additions & 2 deletions backend/prompts.json
Original file line number Diff line number Diff line change
@@ -22,10 +22,15 @@
"voice_id": "9Fa9ozDyMkNFPnyRbRZD",
"model": "eleven_multilingual_v2"
},
"waldemar_puto": {
"prompt_id": "puto_arrombado_xinga_demais",
"voice_id": "9Fa9ozDyMkNFPnyRbRZD",
"model": "eleven_multilingual_v2"
},
"pescador_puto": {
"prompt_id": "objetivo_pescador",
"voice_id": "t0jbNlBVZ17f02VDIeMI",
"model": "eleven_multilingual_v1"
"model": "eleven_multilingual_v2"
},
"asmr_puto": {
"prompt_id": "objetivo_relaxar_asmr",
@@ -35,7 +40,7 @@
"padeiro_puto": {
"prompt_id": "objetivo_padeiro",
"voice_id": "ZQe5CZNOzWyzPSCn5a3c",
"model": "eleven_multilingual_v1"
"model": "eleven_multilingual_v2"
}
},
"current_personality_id": "waldemar"
59 changes: 59 additions & 0 deletions backend/src/components/tabs/elevenlabs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from elevenlabs import Voice
import gradio as gr
from src.tts import tts
from src.config import global_config
from loguru import logger


@@ -41,6 +43,25 @@ def gen_voices_html():
return gr.HTML(full_html)


def delete_voice(voice_id: str) -> str:
voice = Voice(voice_id=voice_id)
try:
voice.delete()
logger.info(f"Voice {voice_id} deleted")
return "Voice deleted with success!"
except Exception as e:
logger.info(f"Failed to delete {voice_id} error: {e}")
return f"Failed to delete voice error: {e}"


def set_voice_settings(stability: float, style: float, similarity_boost: float):
global_config.voice_stability = stability
global_config.voice_style = style
global_config.voice_similarity_boost = similarity_boost
global_config.save()
return "Voice settings updated with success!"


def elevenlabs_tab():
with gr.Tab("Elevenlabs") as tab:
with gr.Tab("Available Voices"):
@@ -68,4 +89,42 @@ def elevenlabs_tab():
allow_flagging="never",
)

with gr.Tab("Delete Voice Clone"):
gr.Interface(
fn=delete_voice,
inputs=[gr.Textbox(label="Voice ID to delete")],
outputs="text",
allow_flagging="never",
)

with gr.Tab("Voice Settings"):
gr.Interface(
fn=set_voice_settings,
inputs=[
gr.Slider(
label="Stability",
value=global_config.voice_stability,
minimum=0.01,
maximum=1.00,
step=0.01,
),
gr.Slider(
label="Style",
value=global_config.voice_style,
minimum=0.01,
maximum=1.00,
step=0.01,
),
gr.Slider(
label="Similarity Boost",
value=global_config.voice_similarity_boost,
minimum=0.01,
maximum=1.00,
step=0.01,
),
],
outputs="text",
allow_flagging="never",
)

return tab
4 changes: 4 additions & 0 deletions backend/src/config.py
Original file line number Diff line number Diff line change
@@ -49,6 +49,10 @@ class GlobalConfig:
elevenlabs_voice_id: str = env_or_default("ELEVENLABS_VOICE_ID")
elevenlabs_model: Optional[str] = env_or_default("ELEVENLABS_MODEL", "eleven_multilingual_v2")

voice_stability: Optional[float] = float(env_or_default("VOICE_STABILITY", "0.30"))
voice_similarity_boost: Optional[float] = float(env_or_default("VOICE_SIMILARITY_BOOST", "0.75"))
voice_style: Optional[float] = float(env_or_default("VOICE_STYLE", "0.40"))

narrator_volume: int = int(env_or_default("NARRATOR_VOLUME", "100"))

discord_webhook_key: Optional[str] = env_or_default("DISCORD_WEBHOOK_KEY")
6 changes: 5 additions & 1 deletion backend/src/tts.py
Original file line number Diff line number Diff line change
@@ -79,7 +79,11 @@ def non_stream():
logger.info(f"Using {global_config.elevenlabs_buffer_size} elevenlabs buffer size")
voice = Voice(
voice_id=global_config.elevenlabs_voice_id,
settings=VoiceSettings(stability=0.05, similarity_boost=0.75, style=0.75),
settings=VoiceSettings(
stability=global_config.voice_stability, # type: ignore
similarity_boost=global_config.voice_similarity_boost, # type: ignore
style=global_config.voice_style,
),
)

gen = generate(

0 comments on commit bd7ffc4

Please sign in to comment.