fixed timer

This commit is contained in:
maglore9900 2024-09-13 23:26:41 -04:00
parent 90e581eb0e
commit d70de29052
5 changed files with 20 additions and 18 deletions

View File

@ -9,7 +9,7 @@ while True:
text = graph.spk.listen()
# if text:
# print(f"User: {text}")
if text and "hey" in text.lower() and "max" in text.lower() or text and "hey" in text.lower() and "mac" in text.lower():
if text and "hey" in text.lower() and "max" in text.lower() or text and "hey" in text.lower() and "mac" in text.lower()or text and "amax" in text.lower():
if "exit" in text.lower():
break
print("agent invoked")

View File

@ -109,8 +109,13 @@ class Agent:
@tool("set_timer")
async def set_timer(self, time: str):
"""Sets a timer for the user
convert the user provided time to seconds and then start the timer
Use this tool when the user says 'set timer' or similar words in their query.
convert the user provided time to seconds
then pass the value in seconds as the time paramter.
Examples:
"set a timer for 5 minutes" results in 'time': 300
"start a timer for 10 seconds" results in 'time': 10
Only pass the numerical value of seconds to this tool!!!
"""
return ""
@ -148,19 +153,14 @@ class Agent:
async def timer_tool(self, state: str):
try:
print("> spotify_tool")
print("> timer")
print(f"state: {state}")
tool_action = state['agent_out'][0]
command = (lambda x: x.get('command') or x.get('self'))(tool_action.tool_input)
try:
command = (lambda x: x.get('time') or x.get('self'))(tool_action.tool_input)
if not command:
raise ValueError("No valid command found in tool_input")
subprocess.run(["python", "timer.py", command])
# process = subprocess.Popen(["python", "modules/timer.py", command], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
except Exception as e:
print(f"An error occurred with timer: {e}")
except Exception as e:
subprocess.run(["python", "modules/timer.py", str(command)], shell=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred: {e}")
async def run_query_agent(self, state: list):
@ -296,8 +296,8 @@ class Agent:
answer = agent_out
print(f"answer: {answer}")
if "ToolAgentAction" not in str(agent_out):
return answer
# if "ToolAgentAction" not in str(agent_out):
# return answer

View File

@ -51,7 +51,7 @@ class Speak:
audio_data += audio_chunk
# Capture ambient noise in the first 2 seconds
if i < int(self.sample_rate / self.chunk_size * 2): # First 2 seconds
if i < int(self.sample_rate / self.chunk_size * 1): # First 1 seconds
ambient_noise_data += audio_chunk
finally:

View File

@ -22,6 +22,7 @@ import argparse
from plyer import notification
def start_timer(seconds):
seconds = int(seconds) # Convert to integer
print(f"Timer started for {seconds} seconds...")
time.sleep(seconds) # Sleep for the desired time
notification.notify(

View File

@ -14,6 +14,7 @@ import time
from plyer import notification
def start_timer(seconds):
seconds = int(seconds) # Convert to integer
print(f"Timer started for {seconds} seconds...")
time.sleep(seconds) # Sleep for the desired time
notification.notify(
@ -23,4 +24,4 @@ def start_timer(seconds):
)
# Example: Set a timer for 60 seconds
start_timer(5)
# start_timer(5)