|
|
@ -1,6 +1,7 @@
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv() # take environment variables from .env.
|
|
|
|
load_dotenv() # take environment variables from .env.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import traceback
|
|
|
|
from platformdirs import user_data_dir
|
|
|
|
from platformdirs import user_data_dir
|
|
|
|
import ast
|
|
|
|
import ast
|
|
|
|
import json
|
|
|
|
import json
|
|
|
@ -183,6 +184,7 @@ async def send_messages(websocket: WebSocket):
|
|
|
|
async def listener():
|
|
|
|
async def listener():
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
if not from_user.empty():
|
|
|
|
if not from_user.empty():
|
|
|
|
chunk = await from_user.get()
|
|
|
|
chunk = await from_user.get()
|
|
|
@ -205,7 +207,7 @@ async def listener():
|
|
|
|
|
|
|
|
|
|
|
|
if message["type"] == "audio" and message["format"].startswith("bytes"):
|
|
|
|
if message["type"] == "audio" and message["format"].startswith("bytes"):
|
|
|
|
|
|
|
|
|
|
|
|
if not message["content"]: # If it was nothing / silence
|
|
|
|
if "content" not in message or message["content"] == None: # If it was nothing / silence
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
# Convert bytes to audio file
|
|
|
|
# Convert bytes to audio file
|
|
|
@ -312,7 +314,8 @@ async def listener():
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("New computer message recieved. Breaking.")
|
|
|
|
logger.info("New computer message recieved. Breaking.")
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
|
|
|
|
|
|
|
async def stream_tts_to_device(sentence):
|
|
|
|
async def stream_tts_to_device(sentence):
|
|
|
|
force_task_completion_responses = [
|
|
|
|
force_task_completion_responses = [
|
|
|
|