examples : update elevenlabs scripts to use official python API (#837)

* Update elevenlabs example to use ufficial python API

* Update elevenlabs example to use official python API
This commit is contained in:
DGdev91
2023-05-24 20:11:01 +02:00
committed by GitHub
parent 4e16a8fb63
commit 5e2b3407ef
4 changed files with 22 additions and 22 deletions

View File

@ -1,23 +1,20 @@
import sys
import importlib.util
api_key = "" #Write your https://beta.elevenlabs.io api key here
if not api_key:
print("To use elevenlabs you have to register to https://beta.elevenlabs.io and add your elevenlabs api key to examples/talk-llama/eleven-labs.py")
sys.exit()
if importlib.util.find_spec("elevenlabs") is None:
print("elevenlabs library is not installed, you can install it to your enviroment using 'pip install elevenlabs'")
sys.exit()
from elevenlabs import ElevenLabs
eleven = ElevenLabs(api_key)
from elevenlabs import generate, play, save
# Get a Voice object, by name or UUID
voice = eleven.voices["Arnold"] #Possible Voices: Adam Antoni Arnold Bella Domi Elli Josh
voice = "Arnold" #Possible Voices: Adam Antoni Arnold Bella Domi Elli Josh
# Generate the TTS
audio = voice.generate(str(sys.argv[2:]))
audio = generate(
text=str(sys.argv[2:]),
voice=voice
)
# Save the TTS to a file
audio.save("audio")
save(audio, "audio.mp3")