Advertisement
Guest User

Broken python loop

a guest
Jun 4th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | Source Code | 0 0
  1. def main():
  2.     running = False  # Initial state is not running
  3.  
  4.     while True:  # Forever loop
  5.         if not running:
  6.             wait_for_button_press()  # Wait for button press before starting or resuming
  7.             running = True  # Set running to True when starting or resuming
  8.  
  9.         if running:
  10.             user_text = transcribe_audio()
  11.             paste_text(user_text)
  12.  
  13.             while True:
  14.                 if keyboard.is_pressed('space'):  # Check if space bar was pressed during transcription                  
  15.                     running = False  # Set running to False to pause
  16.                     wait_for_button_press()  # Wait for button press to toggle state
  17.                     running = True  # Set running to True to resume
  18.                     break  # Exit the inner loop to continue transcription
  19.                 else:
  20.                     time.sleep(0.1)  # Small delay to avoid busy-waiting
  21.                     running = True  # Set running to True to resume
  22.                     break # break out of this loop out to the main loop
  23.         continue # continue from the main loop    
  24.  
  25. if __name__ == "__main__":
  26.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement