Extended settings for model voices

master
Drew Bednar 2 years ago
parent 3c5c80624c
commit f3ab9b454b

@ -0,0 +1,40 @@
"""
Uses the Eleven Labs Python library and API to stream audio.
"""
from elevenlabs import Voice, generate, set_api_key, stream, voices
from .settings import savant_settings
set_api_key(savant_settings.eleven_labs_api_key.get_secret_value())
voices = voices()
drew_voice = voices[-1]
drew_voice.settings.stability = 0.3
drew_voice.settings.similarity_boost = 0.9
def get_voice_model(model_name: str, voices: list[Voice]) -> Voice:
target_voice = None
for v in voices:
if v.name == model_name:
target_voice = v
if target_voice is None:
raise ValueError(f"Voice Model: {model_name} not found.")
return target_voice
def generate_audio(input_text: str = "") -> None:
audio_stream = generate(text=input_text, voice=voices[-1], stream=True)
stream(audio_stream)
def main():
while True:
input_text = input("Say something in Drew's voice: ")
generate_audio(input_text=input_text)
if __name__ == "__main__":
main()

@ -10,6 +10,9 @@ class SavantSettings(BaseSettings):
eleven_labs_api_key: SecretStr = Field( eleven_labs_api_key: SecretStr = Field(
default="", description="An optional Eleven Labs API key for text to speech." default="", description="An optional Eleven Labs API key for text to speech."
) )
eleven_labs_model: str = Field(
default="Arnold", description="The text-to-speech model name used in eleven labs audio generation."
)
llm_model_name: str = Field( llm_model_name: str = Field(
default="eachadea_vicuna-7b-1.1", description="The large language model name used in API requests." default="eachadea_vicuna-7b-1.1", description="The large language model name used in API requests."
) )

@ -22,7 +22,7 @@ savant-cli = "chat_savant.cli:main"
[project.optional-dependencies] [project.optional-dependencies]
whisper = ["openai-whisper"] whisper = ["openai-whisper"]
elevenlabs = ["elevenlabs", "mpv"] elevenlabs = ["elevenlabs>=0.2.16,<=0.3.0", "mpv"]
[tool.setuptools] [tool.setuptools]
packages = ["chat_savant"] packages = ["chat_savant"]

@ -10,6 +10,7 @@ SETTING_DEFAULTS = {
"OPENAI_API_BASE": "http://localhost:8000/v1", "OPENAI_API_BASE": "http://localhost:8000/v1",
"LLM_MODEL_NAME": "eachadea_vicuna-7b-1.1", "LLM_MODEL_NAME": "eachadea_vicuna-7b-1.1",
"ELEVEN_LABS_API_KEY": "", "ELEVEN_LABS_API_KEY": "",
"ELEVEN_LABS_MODEL": "",
} }

Loading…
Cancel
Save