working transcribe addon !!!
This commit is contained in:
parent
0c5b59ef69
commit
adb595feb8
@ -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
|
import os
|
||||||
from groq import Groq
|
from groq import Groq
|
||||||
import pyaudio
|
import pyaudio
|
||||||
import wave
|
import wave
|
||||||
import pyautogui
|
import pyautogui
|
||||||
import keyboard
|
import keyboard
|
||||||
|
import mouse
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
API_KEY = "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" # Make sure to use your actual API key
|
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
|
# Initialize the Groq client
|
||||||
client = Groq(api_key=API_KEY)
|
client = Groq(api_key=API_KEY)
|
||||||
@ -73,7 +50,7 @@ def transcribe_audio(filename):
|
|||||||
response_format="json", # Optional
|
response_format="json", # Optional
|
||||||
temperature=0.0 # Optional
|
temperature=0.0 # Optional
|
||||||
)
|
)
|
||||||
return transcription['text']
|
return transcription.text
|
||||||
|
|
||||||
def simulate_keypress(text):
|
def simulate_keypress(text):
|
||||||
# Simulate keypress for each character in text
|
# Simulate keypress for each character in text
|
||||||
@ -84,8 +61,10 @@ def simulate_keypress(text):
|
|||||||
def main():
|
def main():
|
||||||
filename = "output.wav"
|
filename = "output.wav"
|
||||||
|
|
||||||
print("Press and hold the button to record...")
|
print("Press and hold the button or left mouse button to record...")
|
||||||
keyboard.wait(BUTTON) # Wait for button press
|
# Wait for button or mouse press
|
||||||
|
while not (keyboard.is_pressed(BUTTON) or mouse.is_pressed(button='left')):
|
||||||
|
pass
|
||||||
record_audio(filename)
|
record_audio(filename)
|
||||||
|
|
||||||
print("Transcribing audio...")
|
print("Transcribing audio...")
|
||||||
|
BIN
agent-mAId/output.wav
Normal file
BIN
agent-mAId/output.wav
Normal file
Binary file not shown.
7
agent-mAId/requirements.txt
Normal file
7
agent-mAId/requirements.txt
Normal file
@ -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
|
BIN
output.wav
Normal file
BIN
output.wav
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user