`bash OS/01/start.sh`
This commit is contained in:
parent
64fc5285fb
commit
61dd64f469
|
@ -1 +1 @@
|
|||
[{"role": "user", "type": "message", "content": "Disgusting.\n"}]
|
||||
[{"role": "user", "type": "message", "content": "And it works really well.\n"}]
|
|
@ -19,9 +19,9 @@ def tts(text):
|
|||
with tempfile.NamedTemporaryFile() as temp_file:
|
||||
response.stream_to_file(temp_file.name)
|
||||
|
||||
# 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)
|
||||
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)
|
||||
|
||||
return temp_file.read()
|
||||
|
|
|
@ -10,6 +10,9 @@ import websockets
|
|||
import queue
|
||||
import pydub
|
||||
import ast
|
||||
from pydub import AudioSegment
|
||||
from pydub.playback import play
|
||||
import io
|
||||
|
||||
# Configuration for Audio Recording
|
||||
CHUNK = 1024 # Record in chunks of 1024 samples
|
||||
|
@ -109,7 +112,18 @@ async def websocket_communication(WS_URL):
|
|||
|
||||
async for message in websocket:
|
||||
print(message)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
if message["type"] == "audio" and "content" in message:
|
||||
audio_bytes = bytes(ast.literal_eval(message["content"]))
|
||||
|
||||
# Convert bytes to audio file
|
||||
audio_file = io.BytesIO(audio_bytes)
|
||||
audio = AudioSegment.from_mp3(audio_file)
|
||||
|
||||
# Play the audio
|
||||
play(audio)
|
||||
|
||||
await asyncio.sleep(1)
|
||||
except:
|
||||
print("Connecting...")
|
||||
await asyncio.sleep(2)
|
||||
|
|
Loading…
Reference in New Issue