mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-24 06:46:37 +00:00
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:
parent
4e16a8fb63
commit
5e2b3407ef
@ -1,23 +1,20 @@
|
|||||||
import sys
|
import sys
|
||||||
import importlib.util
|
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:
|
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'")
|
print("elevenlabs library is not installed, you can install it to your enviroment using 'pip install elevenlabs'")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
from elevenlabs import ElevenLabs
|
from elevenlabs import generate, play, save
|
||||||
eleven = ElevenLabs(api_key)
|
|
||||||
|
|
||||||
# Get a Voice object, by name or UUID
|
# 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
|
# 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
|
# Save the TTS to a file
|
||||||
audio.save("audio")
|
save(audio, "audio.mp3")
|
||||||
|
@ -13,8 +13,11 @@
|
|||||||
say "$2"
|
say "$2"
|
||||||
|
|
||||||
# Eleven Labs
|
# Eleven Labs
|
||||||
# To use it, install the elevenlabs module from pip (pip install elevenlabs), register to https://beta.elevenlabs.io to get an api key and paste it in /examples/talk-llama/eleven-labs.py
|
# To use it, install the elevenlabs module from pip (pip install elevenlabs)
|
||||||
|
# It's possible to use the API for free with limited number of characters. To increase this limit register to https://beta.elevenlabs.io to get an api key and paste it after 'ELEVEN_API_KEY='
|
||||||
|
#Keep the line commented to use the free version whitout api key
|
||||||
#
|
#
|
||||||
|
#export ELEVEN_API_KEY=your_api_key
|
||||||
#wd=$(dirname $0)
|
#wd=$(dirname $0)
|
||||||
#script=$wd/eleven-labs.py
|
#script=$wd/eleven-labs.py
|
||||||
#python3 $script $1 "$2" >/dev/null 2>&1
|
#python3 $script $1 "$2" >/dev/null 2>&1
|
||||||
|
@ -1,23 +1,20 @@
|
|||||||
import sys
|
import sys
|
||||||
import importlib.util
|
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/eleven-labs.py")
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
if importlib.util.find_spec("elevenlabs") is None:
|
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'")
|
print("elevenlabs library is not installed, you can install it to your enviroment using 'pip install elevenlabs'")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
from elevenlabs import ElevenLabs
|
from elevenlabs import generate, play, save
|
||||||
eleven = ElevenLabs(api_key)
|
|
||||||
|
|
||||||
# Get a Voice object, by name or UUID
|
# 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
|
# 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
|
# Save the TTS to a file
|
||||||
audio.save("audio")
|
save(audio, "audio.mp3")
|
||||||
|
@ -13,8 +13,11 @@
|
|||||||
say "$2"
|
say "$2"
|
||||||
|
|
||||||
# Eleven Labs
|
# Eleven Labs
|
||||||
# To use it, install the elevenlabs module from pip (pip install elevenlabs), register to https://beta.elevenlabs.io to get an api key and paste it in /examples/talk/eleven-labs.py
|
# To use it, install the elevenlabs module from pip (pip install elevenlabs)
|
||||||
|
# It's possible to use the API for free with limited number of characters. To increase this limit register to https://beta.elevenlabs.io to get an api key and paste it after 'ELEVEN_API_KEY='
|
||||||
|
#Keep the line commented to use the free version whitout api key
|
||||||
#
|
#
|
||||||
|
#export ELEVEN_API_KEY=your_api_key
|
||||||
#wd=$(dirname $0)
|
#wd=$(dirname $0)
|
||||||
#script=$wd/eleven-labs.py
|
#script=$wd/eleven-labs.py
|
||||||
#python3 $script $1 "$2"
|
#python3 $script $1 "$2"
|
||||||
|
Loading…
Reference in New Issue
Block a user