From d0857f71707f57639634bdad7d936ad644caa4ba Mon Sep 17 00:00:00 2001 From: killian <63927363+KillianLucas@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:34:50 -0800 Subject: [PATCH] 8th Architecture --- OS/01/conversations/user.json | 2 +- OS/01/requirements.txt | 1 + OS/01/start.sh | 2 +- OS/01/tts.py | 8 +++----- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/OS/01/conversations/user.json b/OS/01/conversations/user.json index 8885753..79efc11 100644 --- a/OS/01/conversations/user.json +++ b/OS/01/conversations/user.json @@ -1 +1 @@ -[{"role": "user", "type": "message", "content": "Hi, please just immediately run print hello world, don't do anything else.\n"}, {"role": "user", "type": "message", "content": "Can you calculate something like 1,933 times 2,345? Again, please just do it immediately. Don't do anything else. Just please run the code. Don't send a message to me.\n"}] \ No newline at end of file +[{"role": "user", "type": "message", "content": "Hi.\n"}] \ No newline at end of file diff --git a/OS/01/requirements.txt b/OS/01/requirements.txt index 63a9d47..6e70eb4 100644 --- a/OS/01/requirements.txt +++ b/OS/01/requirements.txt @@ -5,6 +5,7 @@ pynput fastapi uvicorn websockets +playsound python-dotenv ffmpeg-python textual diff --git a/OS/01/start.sh b/OS/01/start.sh index 3c44810..77a66a8 100755 --- a/OS/01/start.sh +++ b/OS/01/start.sh @@ -49,7 +49,7 @@ fi # brew update # brew install portaudio ffmpeg # fi -# pip install -r requirements.txt +python -m pip install -r requirements.txt ### START diff --git a/OS/01/tts.py b/OS/01/tts.py index 027dfc5..024da65 100644 --- a/OS/01/tts.py +++ b/OS/01/tts.py @@ -6,6 +6,7 @@ import tempfile from openai import OpenAI from pydub import AudioSegment from pydub.playback import play +from playsound import playsound client = OpenAI() @@ -16,13 +17,10 @@ def tts(text, play_audio): input=text, response_format="mp3" ) - with tempfile.NamedTemporaryFile() as temp_file: + with tempfile.NamedTemporaryFile(suffix=".mp3") as temp_file: response.stream_to_file(temp_file.name) if play_audio: - audio = AudioSegment.from_file(temp_file.name, format="mp3") - # Gradual fade in and out over 0.2 seconds - audio = audio.fade_in(200).fade_out(200) - play(audio) + playsound(temp_file.name) return temp_file.read()