kind of working

This commit is contained in:
Mikan
2025-08-30 17:39:09 +03:00
parent 26cd36218f
commit 4c1c1a542d
3 changed files with 25 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
"ru": {
"удали слово": "backspace_word",
"удали слова": "backspace_word",
"удали все": "clear_all",
"очисти всё": "clear_all",
"новая строка": "new_line",
"точка": "period",

21
main.py
View File

@@ -19,6 +19,7 @@ class VoiceTextInput:
self.is_active = False
self.language = DEFAULT_LANGUAGE
self.audio_buffer = []
self.is_active_typing = False
# Блокируем pyautogui на случай, если он заблокирован
pyautogui.FAILSAFE = False
@@ -101,6 +102,14 @@ class VoiceTextInput:
self.change_language()
return
if self.is_active_typing_command(text):
self.is_active_typing = not self.is_active_typing
print(f"Ввод текста: {"" if self.is_active_typing else "не"} активирован")
return
if not self.is_active_typing:
return
# Проверяем, является ли текст командой
action_string = self.command_handler.get_command_action(text, self.language)
if action_string:
@@ -140,6 +149,18 @@ class VoiceTextInput:
except Exception as e:
print(f"Ошибка при смене языка: {e}")
def is_active_typing_command(self, text):
change_commands = {
'ru': ['активировать ввод', 'деактивировать ввод', 'включить ввод', 'выключить ввод', "начни печатать", "хватит печатать"],
'en': ['start typing', 'stop typing', 'start writing', 'stop writing']
}
text_lower = text.lower().strip()
for lang in change_commands:
for cmd in change_commands[lang]:
if cmd == text_lower:
return True
return False
if __name__ == "__main__":
app = VoiceTextInput()

View File

@@ -47,6 +47,9 @@ class TextInput:
# Вставляем текст с помощью горячих клавиш (Ctrl+V)
pyautogui.hotkey('ctrl', 'v')
if original_clipboard:
pyperclip.copy(original_clipboard)
except Exception as e:
print(f"Ошибка при вводе через clipboard: {e}")