diff --git a/.gitignore b/.gitignore index ffe6b33..0abf9bb 100644 --- a/.gitignore +++ b/.gitignore @@ -160,4 +160,4 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ -OS/01/conversations/user.json + diff --git a/OS/01/.env.example b/OS/01/.env.example new file mode 100644 index 0000000..d55c875 --- /dev/null +++ b/OS/01/.env.example @@ -0,0 +1,31 @@ +### SETTINGS +# Copy this file and rename it to ".env" to use it. + +# If ALL_LOCAL is False, we'll use OpenAI's services +# If setting ALL_LOCAL to true, set the path to the WHISPER local model +ALL_LOCAL=False +# WHISPER_MODEL_PATH=... +# OPENAI_API_KEY=sk-... + +# For TTS, we use the en_US-lessac-medium voice model by default +# Please change the voice URL and voice name if you wish to use another voice +export PIPER_VOICE_URL="https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/" +export PIPER_VOICE_NAME="en_US-lessac-medium.onnx" + +# If SERVER_START, this is where we'll serve the server. +# If DEVICE_START, this is where the device expects the server to be. +SERVER_URL=ws://localhost:8000/ +SERVER_START=True +DEVICE_START=True + +# Control where various operations happen— can be `device` or `server`. +CODE_RUNNER=server +TTS_RUNNER=server # If device, audio will be sent over websocket. +STT_RUNNER=device # If server, audio will be sent over websocket. + +# Will expose the server publically and display that URL. +SERVER_EXPOSE_PUBLICALLY=False + +# Debug level +# LOG_LEVEL=DEBUG +LOG_LEVEL="INFO" \ No newline at end of file diff --git a/OS/01/.gitignore b/OS/01/.gitignore new file mode 100644 index 0000000..731ab70 --- /dev/null +++ b/OS/01/.gitignore @@ -0,0 +1 @@ +conversations/user.json \ No newline at end of file diff --git a/OS/01/device.py b/OS/01/device.py index 6a1e24f..eb03cdd 100644 --- a/OS/01/device.py +++ b/OS/01/device.py @@ -1,3 +1,6 @@ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + import asyncio import threading import os diff --git a/OS/01/i.py b/OS/01/i.py index 339298f..0c24c49 100644 --- a/OS/01/i.py +++ b/OS/01/i.py @@ -1,3 +1,6 @@ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + import os import glob import json diff --git a/OS/01/llm.py b/OS/01/llm.py index 49a39bc..ba761a3 100644 --- a/OS/01/llm.py +++ b/OS/01/llm.py @@ -1,3 +1,6 @@ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + import os import subprocess from pathlib import Path diff --git a/OS/01/run.py b/OS/01/run.py index 44a365b..f3a558e 100644 --- a/OS/01/run.py +++ b/OS/01/run.py @@ -2,6 +2,10 @@ Exposes a SSE streaming server endpoint at /run, which recieves language and code, and streams the output. """ + +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + import os import json from interpreter import interpreter diff --git a/OS/01/server.py b/OS/01/server.py index 5986c48..cc6cbc9 100644 --- a/OS/01/server.py +++ b/OS/01/server.py @@ -1,3 +1,6 @@ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + from starlette.websockets import WebSocketDisconnect import ast import json diff --git a/OS/01/start.sh b/OS/01/start.sh index 8a4dcc6..95ce705 100755 --- a/OS/01/start.sh +++ b/OS/01/start.sh @@ -1,33 +1,10 @@ -### SETTINGS - -# If ALL_LOCAL is False, we'll use OpenAI's services -# If setting ALL_LOCAL to true, set the path to the WHISPER local model -export ALL_LOCAL=False -# export WHISPER_MODEL_PATH=... -# export OPENAI_API_KEY=sk-... - -# For TTS, we use the en_US-lessac-medium voice model by default -# Please change the voice URL and voice name if you wish to use another voice -export PIPER_VOICE_URL="https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/lessac/medium/" -export PIPER_VOICE_NAME="en_US-lessac-medium.onnx" - -# If SERVER_START, this is where we'll serve the server. -# If DEVICE_START, this is where the device expects the server to be. -export SERVER_URL=ws://localhost:8000/ -export SERVER_START=True -export DEVICE_START=True - -# Control where various operations happen— can be `device` or `server`. -export CODE_RUNNER=server -export TTS_RUNNER=server # If device, audio will be sent over websocket. -export STT_RUNNER=device # If server, audio will be sent over websocket. - -# Will expose the server publically and display that URL. -export SERVER_EXPOSE_PUBLICALLY=False - -# Debug level -# export LOG_LEVEL=DEBUG -export LOG_LEVEL="INFO" +### Import Environment Variables from .env +if [ ! -f ".env" ]; then + echo "Error: .env file does not exist. To create one, see .env.example for an example." + exit 1 +fi +set -a; source .env; set +a + ### SETUP diff --git a/OS/01/stt.py b/OS/01/stt.py index aa14e24..48a6494 100644 --- a/OS/01/stt.py +++ b/OS/01/stt.py @@ -2,6 +2,9 @@ Defines a function which takes a path to an audio file and turns it into text. """ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + from datetime import datetime import os import contextlib diff --git a/OS/01/tts.py b/OS/01/tts.py index e51972a..9093c51 100644 --- a/OS/01/tts.py +++ b/OS/01/tts.py @@ -2,6 +2,9 @@ Defines a function which takes text and returns a path to an audio file. """ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + import tempfile from openai import OpenAI from pydub import AudioSegment diff --git a/OS/01/utils/kernel.py b/OS/01/utils/kernel.py index 7f1bb3c..994e6fb 100644 --- a/OS/01/utils/kernel.py +++ b/OS/01/utils/kernel.py @@ -1,3 +1,6 @@ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + import asyncio import subprocess import platform diff --git a/OS/01/utils/logs.py b/OS/01/utils/logs.py index a73dea1..5aca8bb 100644 --- a/OS/01/utils/logs.py +++ b/OS/01/utils/logs.py @@ -1,3 +1,6 @@ +from dotenv import load_dotenv +load_dotenv() # take environment variables from .env. + import os import logging diff --git a/README.md b/README.md index 5350605..74a97c3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,11 @@ Official repository for [The 01 Project](https://twitter.com/hellokillian/status
-## Setup +## Configuration: + +Copy the OS/01/.env.example file to OS/01/.env and then configure the environment variables within the file. + +## Install Required Libraries: ```bash # MacOS