8th Architecture
This commit is contained in:
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
|
||||
uvicorn
|
||||
websockets
|
||||
playsound
|
||||
python-dotenv
|
||||
ffmpeg-python
|
||||
textual
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue