remove excess print statements
This commit is contained in:
parent
bf7c81b250
commit
9e04e2c5de
|
@ -89,6 +89,7 @@ class Device:
|
|||
self.audiosegments = []
|
||||
self.server_url = ""
|
||||
self.ctrl_pressed = False
|
||||
# self.latency = None
|
||||
|
||||
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."""
|
||||
|
@ -153,6 +154,10 @@ class Device:
|
|||
while True:
|
||||
try:
|
||||
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)
|
||||
self.audiosegments.remove(audio)
|
||||
await asyncio.sleep(0.1)
|
||||
|
@ -203,6 +208,7 @@ class Device:
|
|||
stream.stop_stream()
|
||||
stream.close()
|
||||
print("Recording stopped.")
|
||||
# self.latency = time.time()
|
||||
|
||||
duration = wav_file.getnframes() / RATE
|
||||
if duration < 0.3:
|
||||
|
@ -340,8 +346,8 @@ class Device:
|
|||
await asyncio.sleep(0.01)
|
||||
chunk = await websocket.recv()
|
||||
|
||||
# logger.debug(f"Got this message from the server: {type(chunk)} {chunk}")
|
||||
print((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}"))
|
||||
if type(chunk) == str:
|
||||
chunk = json.loads(chunk)
|
||||
|
||||
|
@ -404,7 +410,7 @@ class Device:
|
|||
async def start_async(self):
|
||||
print("start async was called!!!!!")
|
||||
# Configuration for WebSocket
|
||||
WS_URL = f"ws://{self.server_url}/ws"
|
||||
WS_URL = f"ws://{self.server_url}"
|
||||
# Start the WebSocket communication
|
||||
asyncio.create_task(self.websocket_communication(WS_URL))
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ class AsyncInterpreter:
|
|||
self.interpreter = interpreter
|
||||
|
||||
# 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
|
||||
|
||||
# TTS
|
||||
|
@ -64,7 +66,7 @@ class AsyncInterpreter:
|
|||
if isinstance(chunk, bytes):
|
||||
# It's probably a chunk of audio
|
||||
self.stt.feed_audio(chunk)
|
||||
print("INTERPRETER FEEDING AUDIO")
|
||||
# print("INTERPRETER FEEDING AUDIO")
|
||||
|
||||
else:
|
||||
|
||||
|
@ -88,7 +90,7 @@ class AsyncInterpreter:
|
|||
"""
|
||||
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))
|
||||
|
||||
async def run(self):
|
||||
|
@ -108,21 +110,18 @@ class AsyncInterpreter:
|
|||
while not self._input_queue.empty():
|
||||
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 = self.stt.text()
|
||||
message = self.stt.text()
|
||||
|
||||
message = "hello"
|
||||
print(message)
|
||||
# print(message)
|
||||
|
||||
# print(message)
|
||||
def generate(message):
|
||||
last_lmc_start_flag = self._last_lmc_start_flag
|
||||
self.interpreter.messages = self.active_chat_messages
|
||||
print(
|
||||
"🍀🍀🍀🍀GENERATING, using these messages: ", self.interpreter.messages
|
||||
)
|
||||
print("🍀 🍀 🍀 🍀 active_chat_messages: ", self.active_chat_messages)
|
||||
# print("🍀🍀🍀🍀GENERATING, using these messages: ", self.interpreter.messages)
|
||||
# print("🍀 🍀 🍀 🍀 active_chat_messages: ", self.active_chat_messages)
|
||||
print("message is", message)
|
||||
|
||||
for chunk in self.interpreter.chat(message, display=True, stream=True):
|
||||
|
@ -188,7 +187,7 @@ class AsyncInterpreter:
|
|||
await asyncio.sleep(0.1)
|
||||
while True:
|
||||
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():
|
||||
self.add_to_output_queue_sync(
|
||||
{
|
||||
|
@ -201,7 +200,7 @@ class AsyncInterpreter:
|
|||
break
|
||||
|
||||
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)
|
||||
|
||||
def on_tts_chunk(self, chunk):
|
||||
|
|
|
@ -57,9 +57,9 @@ async def main():
|
|||
await interpreter.input(data)
|
||||
elif "bytes" in data:
|
||||
await interpreter.input(data["bytes"])
|
||||
print("SERVER FEEDING AUDIO")
|
||||
# print("SERVER FEEDING AUDIO")
|
||||
elif "text" in data:
|
||||
print("RECEIVED INPUT", data)
|
||||
# print("RECEIVED INPUT", data)
|
||||
await interpreter.input(data["text"])
|
||||
|
||||
async def send_output():
|
|
@ -5,7 +5,7 @@ import threading
|
|||
import os
|
||||
import importlib
|
||||
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
|
||||
|
||||
import signal
|
||||
|
@ -103,7 +103,7 @@ def run(
|
|||
def _run(
|
||||
server: bool = False,
|
||||
server_host: str = "0.0.0.0",
|
||||
server_port: int = 8000,
|
||||
server_port: int = 10001,
|
||||
tunnel_service: str = "bore",
|
||||
expose: bool = False,
|
||||
client: bool = False,
|
||||
|
@ -152,18 +152,18 @@ def _run(
|
|||
target=loop.run_until_complete,
|
||||
args=(
|
||||
main(
|
||||
# server_host,
|
||||
# server_port,
|
||||
# llm_service,
|
||||
# model,
|
||||
# llm_supports_vision,
|
||||
# llm_supports_functions,
|
||||
# context_window,
|
||||
# max_tokens,
|
||||
# temperature,
|
||||
# tts_service,
|
||||
# stt_service,
|
||||
# mobile,
|
||||
server_host,
|
||||
server_port,
|
||||
llm_service,
|
||||
model,
|
||||
llm_supports_vision,
|
||||
llm_supports_functions,
|
||||
context_window,
|
||||
max_tokens,
|
||||
temperature,
|
||||
tts_service,
|
||||
stt_service,
|
||||
mobile,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
@ -196,7 +196,7 @@ def _run(
|
|||
module = importlib.import_module(
|
||||
f".clients.{client_type}.device", package="source"
|
||||
)
|
||||
server_url = "0.0.0.0:8000"
|
||||
|
||||
client_thread = threading.Thread(target=module.main, args=[server_url])
|
||||
print("client thread started")
|
||||
client_thread.start()
|
||||
|
|
Loading…
Reference in New Issue