]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
examples : update elevenlabs scripts to use official python API (#837)
authorDGdev91 <redacted>
Wed, 24 May 2023 18:11:01 +0000 (20:11 +0200)
committerGitHub <redacted>
Wed, 24 May 2023 18:11:01 +0000 (21:11 +0300)
* Update elevenlabs example to use ufficial python API

* Update elevenlabs example to use official python API

examples/talk-llama/eleven-labs.py
examples/talk-llama/speak.sh
examples/talk/eleven-labs.py
examples/talk/speak.sh

index 56855fb3721b5c3f23c1f86c4eeb90fa5fe0d472..edcd023b043ad00be6072eee7c8f6e6f3290d27d 100644 (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") 
index 62982a304de0c7a1ce54233bb0a92fef5b9705da..40fdad2d0bb13bd8148404b0edd5e64005f6f1dd 100755 (executable)
 say "$2"
 
 # 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)
 #script=$wd/eleven-labs.py
 #python3 $script $1 "$2" >/dev/null 2>&1
index 6a4e8db02d979e09e32dd87162a376eb67c998d5..edcd023b043ad00be6072eee7c8f6e6f3290d27d 100644 (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/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") 
index e03786e955fddd0ebc33dcee8cb0b78b0f36f4c9..f6954d121e08a5e5fda92b5c7cb7f2b10502f1b6 100755 (executable)
 say "$2"
 
 # 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)
 #script=$wd/eleven-labs.py
 #python3 $script $1 "$2"