-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_selected.py
54 lines (41 loc) · 1.28 KB
/
copy_selected.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import keyboard
import pyautogui
import pyperclip
import time
import loguru
import os
from src.voice_handler import main as voice_generation
os.environ["DISPLAY"] = ":0"
logger = loguru.logger
def save_to_file():
"""
Saves the selected text to a file by performing the following steps:
1. Copies the selected text to the clipboard.
2. Logs the selected text.
3. Generates voice using the selected text.
4. Logs a message indicating that the request was made.
This function does not take any parameters.
This function does not return any values.
"""
pyautogui.hotkey("ctrl", "c")
time.sleep(0.5)
selected_text = pyperclip.paste()
logger.info(f"selected text: {selected_text}")
voice_generation(
voice_id="XrExE9yKIg1WjnnlVkGX", text=selected_text, out_path="./src/audio/out/"
)
logger.info("request made")
exit()
def main():
"""
Adds a hotkey to save the highlighted text to a file when 'Ctrl+Alt+S' is pressed.
Parameters:
None
Return:
None
"""
keyboard.add_hotkey("ctrl+alt+s", save_to_file)
logger.info("Waiting for 'Ctrl+Alt+S' to save highlighted text to file...")
keyboard.wait()
if __name__ == "__main__":
main()