[dotenv] module added and README updated with information on how to use. Also, small README format refactor. (#5)
This commit is contained in:
parent
e074efb942
commit
604c2b5624
|
@ -0,0 +1,8 @@
|
||||||
|
# Required variables:
|
||||||
|
export OPENAI_API_KEY=
|
||||||
|
export ELEVENLABS_API_KEY=
|
||||||
|
export ELEVENLABS_VOICE_ID=
|
||||||
|
|
||||||
|
# Optional variables:
|
||||||
|
export ELEVENLABS_STREAMING=
|
||||||
|
export PHOTOBOOTH_MODE=
|
20
README.md
20
README.md
|
@ -1,4 +1,4 @@
|
||||||
# David Attenborough narrates your life.
|
# David Attenborough narrates your life
|
||||||
|
|
||||||
https://twitter.com/charliebholtz/status/1724815159590293764
|
https://twitter.com/charliebholtz/status/1724815159590293764
|
||||||
|
|
||||||
|
@ -32,12 +32,6 @@ Make a new voice in Eleven and get the voice id of that voice using their [get v
|
||||||
export ELEVENLABS_VOICE_ID=<voice-id>
|
export ELEVENLABS_VOICE_ID=<voice-id>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Script
|
|
||||||
|
|
||||||
Alternative to running the commands above individually, one can use the `setup.sh` script to facilitate getting the two required shell envs ready to rock by updating the environment variable values in `setup.sh` and executing the script.
|
|
||||||
|
|
||||||
_Note: may have to manually run `source source venv/bin/activate` afterwards depending on shell env._
|
|
||||||
|
|
||||||
## Run it!
|
## Run it!
|
||||||
|
|
||||||
In on terminal, run the webcam capture:
|
In on terminal, run the webcam capture:
|
||||||
|
@ -54,6 +48,18 @@ python narrator.py
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
#### Script
|
||||||
|
|
||||||
|
Alternative to running the [Setup](#setup) commands above individually, one can use the `setup.sh` script to facilitate getting the two required shell envs ready to rock.
|
||||||
|
|
||||||
|
_Note: may have to manually run `source source venv/bin/activate` afterwards depending on shell env._
|
||||||
|
|
||||||
|
#### Dotenv
|
||||||
|
|
||||||
|
One can set the environment variables via the `.env` file, which is read every time the process starts. It is recommended to copy the `.env.example` file and rename to `.env`.
|
||||||
|
|
||||||
### Streaming
|
### Streaming
|
||||||
|
|
||||||
If you would like the speech to start quicker via a streaming manner set the environment variable to enable. The concession is that the audio snippet is not saved in the `/narration` directory.
|
If you would like the speech to start quicker via a streaming manner set the environment variable to enable. The concession is that the audio snippet is not saved in the `/narration` directory.
|
||||||
|
|
|
@ -3,12 +3,16 @@ import errno
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from dotenv import load_dotenv
|
||||||
from elevenlabs import generate, play, set_api_key, stream
|
from elevenlabs import generate, play, set_api_key, stream
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
from pynput import ( # Using pynput to listen for a keypress instead of native keyboard module which was requiring admin privileges
|
from pynput import ( # Using pynput to listen for a keypress instead of native keyboard module which was requiring admin privileges
|
||||||
keyboard,
|
keyboard,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# import environment variables from .env file
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
client = OpenAI()
|
client = OpenAI()
|
||||||
|
|
||||||
set_api_key(os.environ.get("ELEVENLABS_API_KEY"))
|
set_api_key(os.environ.get("ELEVENLABS_API_KEY"))
|
||||||
|
|
|
@ -29,6 +29,7 @@ pydantic==2.4.2
|
||||||
pydantic_core==2.10.1
|
pydantic_core==2.10.1
|
||||||
Pygments==2.16.1
|
Pygments==2.16.1
|
||||||
pynput==1.7.6
|
pynput==1.7.6
|
||||||
|
python-dotenv==1.0.0
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
simpleaudio==1.0.4
|
simpleaudio==1.0.4
|
||||||
six==1.16.0
|
six==1.16.0
|
||||||
|
|
9
setup.sh
9
setup.sh
|
@ -4,15 +4,10 @@
|
||||||
python3 -m pip install virtualenv
|
python3 -m pip install virtualenv
|
||||||
python3 -m virtualenv venv
|
python3 -m virtualenv venv
|
||||||
|
|
||||||
# source the virtual environment
|
# source the virtual environment to install dependencies
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
|
|
||||||
# install the dependencies
|
# install the dependencies
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
# set the environment variables
|
echo -e "\n\n\nSetup complete. Run $(source venv/bin/activate) to activate the virtual environment.\n\nAlso, please ensure your environment variables are set correctly in the .env file."
|
||||||
export ELEVENLABS_VOICE_ID=
|
|
||||||
export OPENAI_API_KEY=
|
|
||||||
export ELEVENLABS_API_KEY=
|
|
||||||
|
|
||||||
export ELEVENLABS_STREAMING=false
|
|
||||||
|
|
Loading…
Reference in New Issue