Skip to content

Commit 001083a

Browse files
authored
talk, talk-llama : add basic example script for eleven-labs tts (ggml-org#728)
1 parent 62b51c3 commit 001083a

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

examples/talk-llama/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
eleven-labs.py
21
audio.mp3

examples/talk-llama/eleven-labs.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
import importlib.util
3+
4+
api_key = "" #Write your https://beta.elevenlabs.io api key here
5+
if not api_key:
6+
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")
7+
sys.exit()
8+
9+
if importlib.util.find_spec("elevenlabs") is None:
10+
print("elevenlabs library is not installed, you can install it to your enviroment using 'pip install elevenlabs'")
11+
sys.exit()
12+
13+
from elevenlabs import ElevenLabs
14+
eleven = ElevenLabs(api_key)
15+
16+
# Get a Voice object, by name or UUID
17+
voice = eleven.voices["Arnold"] #Possible Voices: Adam Antoni Arnold Bella Domi Elli Josh
18+
19+
# Generate the TTS
20+
audio = voice.generate(str(sys.argv[2:]))
21+
22+
# Save the TTS to a file
23+
audio.save("audio")

examples/talk-llama/speak.sh

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
say "$2"
1414

1515
# Eleven Labs
16+
# 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
1617
#
1718
#wd=$(dirname $0)
1819
#script=$wd/eleven-labs.py

examples/talk/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eleven-labs.py
1+
audio.mp3

examples/talk/eleven-labs.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
import importlib.util
3+
4+
api_key = "" #Write your https://beta.elevenlabs.io api key here
5+
if not api_key:
6+
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")
7+
sys.exit()
8+
9+
if importlib.util.find_spec("elevenlabs") is None:
10+
print("elevenlabs library is not installed, you can install it to your enviroment using 'pip install elevenlabs'")
11+
sys.exit()
12+
13+
from elevenlabs import ElevenLabs
14+
eleven = ElevenLabs(api_key)
15+
16+
# Get a Voice object, by name or UUID
17+
voice = eleven.voices["Arnold"] #Possible Voices: Adam Antoni Arnold Bella Domi Elli Josh
18+
19+
# Generate the TTS
20+
audio = voice.generate(str(sys.argv[2:]))
21+
22+
# Save the TTS to a file
23+
audio.save("audio")

examples/talk/speak.sh

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
say "$2"
1414

1515
# Eleven Labs
16+
# 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
1617
#
1718
#wd=$(dirname $0)
1819
#script=$wd/eleven-labs.py

0 commit comments

Comments
 (0)