diff --git a/agent-mAId/main.py b/agent-mAId/main.py index 96dd788..af72905 100644 --- a/agent-mAId/main.py +++ b/agent-mAId/main.py @@ -1,37 +1,14 @@ -# let's create a new application which will run in the background at startup, will listen to the microphone while mouse or other (configurable) button is pressed and will send the audio to Whisper and will enter (emulate keypress) of the transcribed text result on key release -# https://console.groq.com/docs/speech-text - -# import system_hooks -# import audio_recorder -# import whisper_api -# import keyboard_emulator - -# def on_button_press(): -# audio_recorder.start_recording() - -# def on_button_release(): -# audio = audio_recorder.stop_recording() -# text = whisper_api.transcribe(audio) -# keyboard_emulator.type_text(text) - -# def main(): -# system_hooks.set_startup_run() -# system_hooks.register_button_callback(on_button_press, on_button_release) -# system_hooks.run_event_loop() - -# if __name__ == "__main__": -# main() - import os from groq import Groq import pyaudio import wave import pyautogui import keyboard +import mouse # Constants API_KEY = "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" # Make sure to use your actual API key -BUTTON = 'ctrl' # The button to listen for +BUTTON = 'ctrl' # The keyboard button to listen for # Initialize the Groq client client = Groq(api_key=API_KEY) @@ -73,7 +50,7 @@ def transcribe_audio(filename): response_format="json", # Optional temperature=0.0 # Optional ) - return transcription['text'] + return transcription.text def simulate_keypress(text): # Simulate keypress for each character in text @@ -84,8 +61,10 @@ def simulate_keypress(text): def main(): filename = "output.wav" - print("Press and hold the button to record...") - keyboard.wait(BUTTON) # Wait for button press + print("Press and hold the button or left mouse button to record...") + # Wait for button or mouse press + while not (keyboard.is_pressed(BUTTON) or mouse.is_pressed(button='left')): + pass record_audio(filename) print("Transcribing audio...") diff --git a/agent-mAId/output.wav b/agent-mAId/output.wav new file mode 100644 index 0000000..36842f9 Binary files /dev/null and b/agent-mAId/output.wav differ diff --git a/agent-mAId/requirements.txt b/agent-mAId/requirements.txt new file mode 100644 index 0000000..13c1fd3 --- /dev/null +++ b/agent-mAId/requirements.txt @@ -0,0 +1,7 @@ +#> pipreqs . + +groq==0.11.0 +keyboard==0.13.5 +mouse==0.7.1 +PyAudio==0.2.14 +PyAutoGUI==0.9.54 diff --git a/output.wav b/output.wav new file mode 100644 index 0000000..9715b30 Binary files /dev/null and b/output.wav differ