-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen_whisperscribe.py
More file actions
37 lines (32 loc) · 1.07 KB
/
Copy pathopen_whisperscribe.py
File metadata and controls
37 lines (32 loc) · 1.07 KB
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
# Configure as background app on macOS (must be done before GUI imports)
from src.macos_background import configure_background_app
configure_background_app()
from pynput import keyboard
import atexit
from src.hotkey_handler import on_press, on_release
from src.audio_recorder import get_stream, reset_stream, set_is_recording
from src.constants import COMBINATION
def cleanup():
try:
stream = get_stream()
if stream:
print("Cleaning up audio stream...")
stream.stop()
stream.close()
reset_stream()
set_is_recording(False)
print("Cleanup complete.")
except Exception as e:
print("Cleanup error.")
atexit.register(cleanup)
def main():
try:
print(f"Hold {' + '.join([k.name for k in COMBINATION])} to record, release to transcribe and paste.")
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
except Exception as e:
print("Main loop error.")
finally:
cleanup()
if __name__ == "__main__":
main()