Skip to content

Commit

Permalink
simulator broken?
Browse files Browse the repository at this point in the history
  • Loading branch information
om-raheja committed Aug 4, 2024
1 parent bae8bac commit 99aa6c5
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pyopenagi/agents/om-raheja/transcribe_agent/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from ...react_agent import ReactAgent

class TranscribeAgent(ReactAgent):
def __init__(self,
agent_name,
task_input,
agent_process_factory,
log_mode: str
):
ReactAgent.__init__(self, agent_name, task_input, agent_process_factory, log_mode)
self.workflow_mode = "automatic"

def manual_workflow(self):
pass

def run(self):
return super().run()
14 changes: 14 additions & 0 deletions pyopenagi/agents/om-raheja/transcribe_agent/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "transcribe_agent",
"description": [
"You are an agent who can transcribe audio from the microphone into text. "
],
"tools": [
"transcriber/transcriber"
],
"meta": {
"author": "Om Raheja",
"version": "0.0.1",
"license": "CC0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RealtimeSTT
52 changes: 52 additions & 0 deletions pyopenagi/tools/transcriber/transcriber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from ..base import BaseTool
from time import sleep

class CurrencyConverter(BaseTool):
def __init__(self):
""" big library, not everyone needs it installed """
try:
from RealtimeSTT import AudioToTextRecorder
except ImportError:
raise ImportError(
"Please install RealtimeSTT: `pip install RealtimeSTT`"
)

# this is hardcoded for now
self.recorder = AudioToTextRecorder(
model="tiny.en",
)

def run(self, params: dict):
duration = 5
try:
duration = int(params["duration"])
except ValueError:
raise KeyError(
"The keys in params do not match the excepted key in params for transcriber api. "
"Please make sure it contain the key 'duration'"
)

self.record.start()
sleep(duration)
self.recorder.stop()
return self.recorder.text()

def get_tool_call_format(self):
tool_call_format = {
"type": "function",
"function": {
"name": "transcriber",
"description": "Transcribes audiio into text",
"parameters": {
"type": "object",
"properties": {
"duration": {
"type": "string",
"description": "How long to record audio for in seconds",
},
},
"required": []
}
}
}
return tool_call_format

0 comments on commit 99aa6c5

Please sign in to comment.