Parametrize voice ID via another environment variable.

This commit is contained in:
Gabor Cselle 2023-11-17 10:50:12 -08:00
parent c985bf5a47
commit b2b76702b3
2 changed files with 8 additions and 3 deletions

View File

@ -25,14 +25,19 @@ export OPENAI_API_KEY=<token>
export ELEVENLABS_API_KEY=<eleven-token> export ELEVENLABS_API_KEY=<eleven-token>
``` ```
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=<voice-id>
```
## Run it! ## Run it!
In on terminal, run the webcam capture:
```bash ```bash
python capture.py python capture.py
``` ```
In one terminal. In the other, run the narrator: In another terminal, run the narrator:
```bash ```bash
python narrator.py python narrator.py

View File

@ -24,7 +24,7 @@ def encode_image(image_path):
def play_audio(text): 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("=") unique_id = base64.urlsafe_b64encode(os.urandom(30)).decode("utf-8").rstrip("=")
dir_path = os.path.join("narration", unique_id) dir_path = os.path.join("narration", unique_id)