From b4623e6492b5cef68e6c1b5f053c9ad6e7eba1f5 Mon Sep 17 00:00:00 2001 From: Tom Chapin Date: Sat, 10 Feb 2024 19:39:17 -0800 Subject: [PATCH 1/5] moving .gitignore config for conversations to project sub-folder --- .gitignore | 2 +- OS/01/.gitignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 OS/01/.gitignore diff --git a/.gitignore b/.gitignore index 91c9774..74958ea 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/.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 From b5164b7dbecc7f94aadf02135defabd92272d664 Mon Sep 17 00:00:00 2001 From: Tom Chapin Date: Sat, 10 Feb 2024 19:39:40 -0800 Subject: [PATCH 2/5] Moving configuration to .env --- OS/01/.env.example | 26 ++++++++++++++++++++++++++ OS/01/start.sh | 31 ++++++------------------------- README.md | 6 +++++- 3 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 OS/01/.env.example diff --git a/OS/01/.env.example b/OS/01/.env.example new file mode 100644 index 0000000..fa11853 --- /dev/null +++ b/OS/01/.env.example @@ -0,0 +1,26 @@ +### 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-... + +# 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 +# DEBUG_LEVEL=DEBUG +DEBUG_LEVEL="INFO" \ No newline at end of file diff --git a/OS/01/start.sh b/OS/01/start.sh index db5689a..5e2c4fd 100755 --- a/OS/01/start.sh +++ b/OS/01/start.sh @@ -1,28 +1,9 @@ -### 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-... - -# 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 DEBUG_LEVEL=DEBUG -export DEBUG_LEVEL="INFO" +### Import config 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/README.md b/README.md index 24057cf..743f4b8 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 From 86e6927269936760f49d88ea9c088639b1e77dc0 Mon Sep 17 00:00:00 2001 From: Tom Chapin Date: Sat, 10 Feb 2024 19:44:49 -0800 Subject: [PATCH 3/5] adding new config variables to the .env --- OS/01/.env.example | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OS/01/.env.example b/OS/01/.env.example index fa11853..d55c875 100644 --- a/OS/01/.env.example +++ b/OS/01/.env.example @@ -7,6 +7,11 @@ 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/ @@ -22,5 +27,5 @@ STT_RUNNER=device # If server, audio will be sent over websocket. SERVER_EXPOSE_PUBLICALLY=False # Debug level -# DEBUG_LEVEL=DEBUG -DEBUG_LEVEL="INFO" \ No newline at end of file +# LOG_LEVEL=DEBUG +LOG_LEVEL="INFO" \ No newline at end of file From 9493912034620b4db2427e6851e1c262afb78935 Mon Sep 17 00:00:00 2001 From: Tom Chapin Date: Sat, 10 Feb 2024 19:44:58 -0800 Subject: [PATCH 4/5] Fixing comment --- OS/01/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OS/01/start.sh b/OS/01/start.sh index 07a9ab4..95ce705 100755 --- a/OS/01/start.sh +++ b/OS/01/start.sh @@ -1,4 +1,4 @@ -### Import config from .env +### 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 From a3537f4a4d1f11871ce37048a05b126720d31916 Mon Sep 17 00:00:00 2001 From: Tom Chapin Date: Sat, 10 Feb 2024 19:53:55 -0800 Subject: [PATCH 5/5] adding python-dotenv --- OS/01/device.py | 3 +++ OS/01/i.py | 3 +++ OS/01/llm.py | 3 +++ OS/01/run.py | 4 ++++ OS/01/server.py | 3 +++ OS/01/stt.py | 3 +++ OS/01/tts.py | 3 +++ OS/01/utils/kernel.py | 3 +++ OS/01/utils/logs.py | 3 +++ 9 files changed, 28 insertions(+) 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/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