diff --git a/pyopenagi/agents/om-raheja/transcribe_agent/agent.py b/pyopenagi/agents/om-raheja/transcribe_agent/agent.py new file mode 100755 index 00000000..b9c3eb57 --- /dev/null +++ b/pyopenagi/agents/om-raheja/transcribe_agent/agent.py @@ -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() diff --git a/pyopenagi/agents/om-raheja/transcribe_agent/config.json b/pyopenagi/agents/om-raheja/transcribe_agent/config.json new file mode 100644 index 00000000..93089ef3 --- /dev/null +++ b/pyopenagi/agents/om-raheja/transcribe_agent/config.json @@ -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" + } +} diff --git a/pyopenagi/agents/om-raheja/transcribe_agent/meta_requirements.txt b/pyopenagi/agents/om-raheja/transcribe_agent/meta_requirements.txt new file mode 100644 index 00000000..d7d6bed4 --- /dev/null +++ b/pyopenagi/agents/om-raheja/transcribe_agent/meta_requirements.txt @@ -0,0 +1 @@ +RealtimeSTT diff --git a/pyopenagi/tools/transcriber/transcriber.py b/pyopenagi/tools/transcriber/transcriber.py new file mode 100644 index 00000000..ce5aa7aa --- /dev/null +++ b/pyopenagi/tools/transcriber/transcriber.py @@ -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