Dodany tryb emacs
This commit is contained in:
parent
2c49d6647d
commit
92901ef364
|
|
@ -13,6 +13,7 @@ model = Model(model_path)
|
||||||
recognizer = KaldiRecognizer(model, 16000)
|
recognizer = KaldiRecognizer(model, 16000)
|
||||||
|
|
||||||
listening = False # Flaga stanu nasłuchiwania
|
listening = False # Flaga stanu nasłuchiwania
|
||||||
|
emacs_mode = False # Flaga trybu Emacs
|
||||||
|
|
||||||
# Funkcja obsługi danych audio
|
# Funkcja obsługi danych audio
|
||||||
def callback(indata, frames, time, status):
|
def callback(indata, frames, time, status):
|
||||||
|
|
@ -31,7 +32,10 @@ def callback(indata, frames, time, status):
|
||||||
def insert_text_with_clipboard(text):
|
def insert_text_with_clipboard(text):
|
||||||
try:
|
try:
|
||||||
pyperclip.copy(text) # Kopiowanie tekstu do schowka
|
pyperclip.copy(text) # Kopiowanie tekstu do schowka
|
||||||
pyautogui.hotkey('ctrl', 'v') # Symulacja wklejania
|
if emacs_mode:
|
||||||
|
pyautogui.hotkey('shift', 'insert') # Wklejanie w trybie Emacs
|
||||||
|
else:
|
||||||
|
pyautogui.hotkey('ctrl', 'v') # Standardowe wklejanie
|
||||||
pyautogui.press('space') # Dodanie spacji (opcjonalne)
|
pyautogui.press('space') # Dodanie spacji (opcjonalne)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Błąd podczas wklejania tekstu: {e}", file=sys.stderr)
|
print(f"Błąd podczas wklejania tekstu: {e}", file=sys.stderr)
|
||||||
|
|
@ -62,12 +66,26 @@ def toggle_listening():
|
||||||
thread.daemon = True
|
thread.daemon = True
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
def toggle_emacs_mode():
|
||||||
|
global emacs_mode
|
||||||
|
emacs_mode = not emacs_mode
|
||||||
|
update_emacs_button_state()
|
||||||
|
mode = "Emacs" if emacs_mode else "Standard"
|
||||||
|
print(f"Tryb wklejania: {mode}")
|
||||||
|
|
||||||
|
# Aktualizacja stanu przycisków
|
||||||
def update_button_state():
|
def update_button_state():
|
||||||
if listening:
|
if listening:
|
||||||
toggle_button.config(text="Stop", bg="red", fg="white")
|
toggle_button.config(text="Stop", bg="red", fg="white")
|
||||||
else:
|
else:
|
||||||
toggle_button.config(text="Start", bg="lightgrey", fg="black")
|
toggle_button.config(text="Start", bg="lightgrey", fg="black")
|
||||||
|
|
||||||
|
def update_emacs_button_state():
|
||||||
|
if emacs_mode:
|
||||||
|
emacs_button.config(text="Tryb: Emacs", bg="blue", fg="white")
|
||||||
|
else:
|
||||||
|
emacs_button.config(text="Tryb: Standard", bg="lightgrey", fg="black")
|
||||||
|
|
||||||
# Funkcja obsługi skrótu klawiszowego
|
# Funkcja obsługi skrótu klawiszowego
|
||||||
def handle_shortcut(event):
|
def handle_shortcut(event):
|
||||||
if event.keysym == 'F1': # F1 jako skrót klawiszowy
|
if event.keysym == 'F1': # F1 jako skrót klawiszowy
|
||||||
|
|
@ -75,15 +93,18 @@ def handle_shortcut(event):
|
||||||
|
|
||||||
# Tworzenie GUI
|
# Tworzenie GUI
|
||||||
def create_gui():
|
def create_gui():
|
||||||
global toggle_button
|
global toggle_button, emacs_button
|
||||||
|
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.title("Vosk Rozpoznawanie Mowy")
|
root.title("Vosk Rozpoznawanie Mowy")
|
||||||
root.geometry("300x150")
|
root.geometry("300x200")
|
||||||
|
|
||||||
toggle_button = tk.Button(root, text="Start", command=toggle_listening, width=15, bg="lightgrey", fg="black")
|
toggle_button = tk.Button(root, text="Start", command=toggle_listening, width=15, bg="lightgrey", fg="black")
|
||||||
toggle_button.pack(pady=10)
|
toggle_button.pack(pady=10)
|
||||||
|
|
||||||
|
emacs_button = tk.Button(root, text="Tryb: Standard", command=toggle_emacs_mode, width=15, bg="lightgrey", fg="black")
|
||||||
|
emacs_button.pack(pady=10)
|
||||||
|
|
||||||
exit_button = tk.Button(root, text="Wyjście", command=root.destroy, width=15)
|
exit_button = tk.Button(root, text="Wyjście", command=root.destroy, width=15)
|
||||||
exit_button.pack(pady=10)
|
exit_button.pack(pady=10)
|
||||||
|
|
||||||
|
|
@ -95,4 +116,3 @@ def create_gui():
|
||||||
# Uruchomienie GUI
|
# Uruchomienie GUI
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
create_gui()
|
create_gui()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue