[Narrator] small refactor for clarity.
This commit is contained in:
parent
604c2b5624
commit
d3d540577e
37
narrator.py
37
narrator.py
|
@ -25,25 +25,6 @@ script = []
|
||||||
narrator = "Sir David Attenborough"
|
narrator = "Sir David Attenborough"
|
||||||
|
|
||||||
|
|
||||||
def on_press(key):
|
|
||||||
if key == keyboard.Key.space:
|
|
||||||
# When space bar is pressed, run the main function which analyzes the image and generates the audio
|
|
||||||
_main()
|
|
||||||
|
|
||||||
|
|
||||||
def on_release(key):
|
|
||||||
if key == keyboard.Key.esc:
|
|
||||||
# Stop listener
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# Create a listener
|
|
||||||
listener = keyboard.Listener(on_press=on_press, on_release=on_release)
|
|
||||||
|
|
||||||
# Start the listener
|
|
||||||
listener.start()
|
|
||||||
|
|
||||||
|
|
||||||
def encode_image(image_path):
|
def encode_image(image_path):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -152,6 +133,24 @@ def main():
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
|
def on_press(key):
|
||||||
|
if key == keyboard.Key.space:
|
||||||
|
# When space bar is pressed, run the main function which analyzes the image and generates the audio
|
||||||
|
_main()
|
||||||
|
|
||||||
|
|
||||||
|
def on_release(key):
|
||||||
|
if key == keyboard.Key.esc:
|
||||||
|
# Stop listener
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
# Create a listener
|
||||||
|
listener = keyboard.Listener(on_press=on_press, on_release=on_release)
|
||||||
|
|
||||||
|
# Start the listener
|
||||||
|
listener.start()
|
||||||
|
|
||||||
if isPhotoBooth:
|
if isPhotoBooth:
|
||||||
print(f"Press the spacebar to trigger {narrator}")
|
print(f"Press the spacebar to trigger {narrator}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue