Extended settings for model voices
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()
|
Loading…
Reference in New Issue