remove excess print statements

pull/279/head
Ben Xu 7 months ago
parent bf7c81b250
commit 9e04e2c5de

@ -89,6 +89,7 @@ class Device:
self.audiosegments = [] self.audiosegments = []
self.server_url = "" self.server_url = ""
self.ctrl_pressed = False self.ctrl_pressed = False
# self.latency = None
def fetch_image_from_camera(self, camera_index=CAMERA_DEVICE_INDEX): def fetch_image_from_camera(self, camera_index=CAMERA_DEVICE_INDEX):
"""Captures an image from the specified camera device and saves it to a temporary file. Adds the image to the captured_images list.""" """Captures an image from the specified camera device and saves it to a temporary file. Adds the image to the captured_images list."""
@ -153,6 +154,10 @@ class Device:
while True: while True:
try: try:
for audio in self.audiosegments: for audio in self.audiosegments:
# if self.latency:
# elapsed_time = time.time() - self.latency
# print(f"Time from request to playback: {elapsed_time} seconds")
# self.latency = None
play(audio) play(audio)
self.audiosegments.remove(audio) self.audiosegments.remove(audio)
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
@ -203,6 +208,7 @@ class Device:
stream.stop_stream() stream.stop_stream()
stream.close() stream.close()
print("Recording stopped.") print("Recording stopped.")
# self.latency = time.time()
duration = wav_file.getnframes() / RATE duration = wav_file.getnframes() / RATE
if duration < 0.3: if duration < 0.3:
@ -340,8 +346,8 @@ class Device:
await asyncio.sleep(0.01) await asyncio.sleep(0.01)
chunk = await websocket.recv() chunk = await websocket.recv()
# logger.debug(f"Got this message from the server: {type(chunk)} {chunk}") logger.debug(f"Got this message from the server: {type(chunk)} {chunk}")
print((f"Got this message from the server: {type(chunk)} {chunk}")) # print((f"Got this message from the server: {type(chunk)} {chunk}"))
if type(chunk) == str: if type(chunk) == str:
chunk = json.loads(chunk) chunk = json.loads(chunk)
@ -404,7 +410,7 @@ class Device:
async def start_async(self): async def start_async(self):
print("start async was called!!!!!") print("start async was called!!!!!")
# Configuration for WebSocket # Configuration for WebSocket
WS_URL = f"ws://{self.server_url}/ws" WS_URL = f"ws://{self.server_url}"
# Start the WebSocket communication # Start the WebSocket communication
asyncio.create_task(self.websocket_communication(WS_URL)) asyncio.create_task(self.websocket_communication(WS_URL))

@ -24,7 +24,9 @@ class AsyncInterpreter:
self.interpreter = interpreter self.interpreter = interpreter
# STT # STT
self.stt = AudioToTextRecorder(use_microphone=False) self.stt = AudioToTextRecorder(
model="tiny", spinner=False, use_microphone=False
)
self.stt.stop() # It needs this for some reason self.stt.stop() # It needs this for some reason
# TTS # TTS
@ -64,7 +66,7 @@ class AsyncInterpreter:
if isinstance(chunk, bytes): if isinstance(chunk, bytes):
# It's probably a chunk of audio # It's probably a chunk of audio
self.stt.feed_audio(chunk) self.stt.feed_audio(chunk)
print("INTERPRETER FEEDING AUDIO") # print("INTERPRETER FEEDING AUDIO")
else: else:
@ -88,7 +90,7 @@ class AsyncInterpreter:
""" """
Synchronous function to add a chunk to the output queue. Synchronous function to add a chunk to the output queue.
""" """
print("ADDING TO QUEUE:", chunk) # print("ADDING TO QUEUE:", chunk)
asyncio.create_task(self._add_to_queue(self._output_queue, chunk)) asyncio.create_task(self._add_to_queue(self._output_queue, chunk))
async def run(self): async def run(self):
@ -108,21 +110,18 @@ class AsyncInterpreter:
while not self._input_queue.empty(): while not self._input_queue.empty():
input_queue.append(self._input_queue.get()) input_queue.append(self._input_queue.get())
print("INPUT QUEUE:", input_queue) # print("INPUT QUEUE:", input_queue)
# message = [i for i in input_queue if i["type"] == "message"][0]["content"] # message = [i for i in input_queue if i["type"] == "message"][0]["content"]
# message = self.stt.text() message = self.stt.text()
message = "hello" # print(message)
print(message)
# print(message) # print(message)
def generate(message): def generate(message):
last_lmc_start_flag = self._last_lmc_start_flag last_lmc_start_flag = self._last_lmc_start_flag
self.interpreter.messages = self.active_chat_messages self.interpreter.messages = self.active_chat_messages
print( # print("🍀🍀🍀🍀GENERATING, using these messages: ", self.interpreter.messages)
"🍀🍀🍀🍀GENERATING, using these messages: ", self.interpreter.messages # print("🍀 🍀 🍀 🍀 active_chat_messages: ", self.active_chat_messages)
)
print("🍀 🍀 🍀 🍀 active_chat_messages: ", self.active_chat_messages)
print("message is", message) print("message is", message)
for chunk in self.interpreter.chat(message, display=True, stream=True): for chunk in self.interpreter.chat(message, display=True, stream=True):
@ -188,7 +187,7 @@ class AsyncInterpreter:
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
while True: while True:
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
print("is_playing", self.tts.is_playing()) # print("is_playing", self.tts.is_playing())
if not self.tts.is_playing(): if not self.tts.is_playing():
self.add_to_output_queue_sync( self.add_to_output_queue_sync(
{ {
@ -201,7 +200,7 @@ class AsyncInterpreter:
break break
async def _on_tts_chunk_async(self, chunk): async def _on_tts_chunk_async(self, chunk):
print("SENDING TTS CHUNK") # print("SENDING TTS CHUNK")
await self._add_to_queue(self._output_queue, chunk) await self._add_to_queue(self._output_queue, chunk)
def on_tts_chunk(self, chunk): def on_tts_chunk(self, chunk):

@ -57,9 +57,9 @@ async def main():
await interpreter.input(data) await interpreter.input(data)
elif "bytes" in data: elif "bytes" in data:
await interpreter.input(data["bytes"]) await interpreter.input(data["bytes"])
print("SERVER FEEDING AUDIO") # print("SERVER FEEDING AUDIO")
elif "text" in data: elif "text" in data:
print("RECEIVED INPUT", data) # print("RECEIVED INPUT", data)
await interpreter.input(data["text"]) await interpreter.input(data["text"])
async def send_output(): async def send_output():

@ -5,7 +5,7 @@ import threading
import os import os
import importlib import importlib
from source.server.tunnel import create_tunnel from source.server.tunnel import create_tunnel
from source.server.ai_server import main from source.server.server import main
from source.server.utils.local_mode import select_local_model from source.server.utils.local_mode import select_local_model
import signal import signal
@ -103,7 +103,7 @@ def run(
def _run( def _run(
server: bool = False, server: bool = False,
server_host: str = "0.0.0.0", server_host: str = "0.0.0.0",
server_port: int = 8000, server_port: int = 10001,
tunnel_service: str = "bore", tunnel_service: str = "bore",
expose: bool = False, expose: bool = False,
client: bool = False, client: bool = False,
@ -152,18 +152,18 @@ def _run(
target=loop.run_until_complete, target=loop.run_until_complete,
args=( args=(
main( main(
# server_host, server_host,
# server_port, server_port,
# llm_service, llm_service,
# model, model,
# llm_supports_vision, llm_supports_vision,
# llm_supports_functions, llm_supports_functions,
# context_window, context_window,
# max_tokens, max_tokens,
# temperature, temperature,
# tts_service, tts_service,
# stt_service, stt_service,
# mobile, mobile,
), ),
), ),
) )
@ -196,7 +196,7 @@ def _run(
module = importlib.import_module( module = importlib.import_module(
f".clients.{client_type}.device", package="source" f".clients.{client_type}.device", package="source"
) )
server_url = "0.0.0.0:8000"
client_thread = threading.Thread(target=module.main, args=[server_url]) client_thread = threading.Thread(target=module.main, args=[server_url])
print("client thread started") print("client thread started")
client_thread.start() client_thread.start()

Loading…
Cancel
Save