8th Architecture

pull/11/head
killian 11 months ago
parent 2a603581b5
commit d0857f7170

@ -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"}] [{"role": "user", "type": "message", "content": "Hi.\n"}]

@ -5,6 +5,7 @@ pynput
fastapi fastapi
uvicorn uvicorn
websockets websockets
playsound
python-dotenv python-dotenv
ffmpeg-python ffmpeg-python
textual textual

@ -49,7 +49,7 @@ fi
# brew update # brew update
# brew install portaudio ffmpeg # brew install portaudio ffmpeg
# fi # fi
# pip install -r requirements.txt python -m pip install -r requirements.txt
### START ### START

@ -6,6 +6,7 @@ import tempfile
from openai import OpenAI from openai import OpenAI
from pydub import AudioSegment from pydub import AudioSegment
from pydub.playback import play from pydub.playback import play
from playsound import playsound
client = OpenAI() client = OpenAI()
@ -16,13 +17,10 @@ def tts(text, play_audio):
input=text, input=text,
response_format="mp3" response_format="mp3"
) )
with tempfile.NamedTemporaryFile() as temp_file: with tempfile.NamedTemporaryFile(suffix=".mp3") as temp_file:
response.stream_to_file(temp_file.name) response.stream_to_file(temp_file.name)
if play_audio: if play_audio:
audio = AudioSegment.from_file(temp_file.name, format="mp3") playsound(temp_file.name)
# Gradual fade in and out over 0.2 seconds
audio = audio.fade_in(200).fade_out(200)
play(audio)
return temp_file.read() return temp_file.read()

Loading…
Cancel
Save