From b2b76702b3f110f1de9b6215b724bb2f233b35cc Mon Sep 17 00:00:00 2001 From: Gabor Cselle Date: Fri, 17 Nov 2023 10:50:12 -0800 Subject: [PATCH 1/2] Parametrize voice ID via another environment variable. --- README.md | 9 +++++++-- narrator.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 33f9b66..c10bdcb 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,19 @@ export OPENAI_API_KEY= export ELEVENLABS_API_KEY= ``` -Make a new voice in Eleven and get the voice id of that voice using their [get voices](https://elevenlabs.io/docs/api-reference/voices) API. +Make a new voice in Eleven and get the voice id of that voice using their [get voices](https://elevenlabs.io/docs/api-reference/voices) API, or by clicking the flask icon next to the voice in the VoiceLab tab. + +``` +export ELEVENLABS_VOICE_ID= +``` ## Run it! +In on terminal, run the webcam capture: ```bash python capture.py ``` -In one terminal. In the other, run the narrator: +In another terminal, run the narrator: ```bash python narrator.py diff --git a/narrator.py b/narrator.py index 0435b47..2c71038 100644 --- a/narrator.py +++ b/narrator.py @@ -24,7 +24,7 @@ def encode_image(image_path): def play_audio(text): - audio = generate(text=text, voice="ENfvYmv6CRqDodDZTieQ", model="eleven_turbo_v2") + audio = generate(text, voice=os.environ.get("ELEVENLABS_VOICE_ID")) unique_id = base64.urlsafe_b64encode(os.urandom(30)).decode("utf-8").rstrip("=") dir_path = os.path.join("narration", unique_id) From f6ccf6f780e692be533d60f21affef659bb2eca0 Mon Sep 17 00:00:00 2001 From: Gabor Cselle Date: Fri, 17 Nov 2023 12:30:59 -0800 Subject: [PATCH 2/2] Actually set Elevenlabs API key from environment variable --- narrator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/narrator.py b/narrator.py index 2c71038..cd086f7 100644 --- a/narrator.py +++ b/narrator.py @@ -5,10 +5,11 @@ import json import time import simpleaudio as sa import errno -from elevenlabs import generate, play, voices +from elevenlabs import generate, play, set_api_key, voices client = OpenAI() +set_api_key(os.environ.get("ELEVENLABS_API_KEY")) def encode_image(image_path): while True: