Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. import pyttsx3
  2. import threading
  3. import time
  4.  
  5. halt = 0
  6.  
  7. class KeyEventThread(threading.Thread):
  8.     def run(self):
  9.         while (True):
  10.             global halt
  11.             #print("Hello")
  12.             #time.sleep(10)
  13.             z = input('Press enter to pause')
  14.             halt = 1
  15.  
  16. kethread = KeyEventThread()
  17. kethread.start()
  18.  
  19. engine = pyttsx3.init()
  20.  
  21. #engine.say('The quick brown fox jumped over the lazy dog.')
  22. #engine.runAndWait()
  23.  
  24. fname = "marks.txt"
  25.  
  26. with open(fname) as f:
  27.     content = f.readlines()
  28. #Remove whitespace characters like `\n` at the end of each line
  29. content = [x.strip() for x in content]
  30.  
  31.  
  32. for mark in content:
  33.     if (halt == 1):
  34.         #break
  35.         time.sleep(10)
  36.         halt = 0
  37.     print ('saying '  +  mark)
  38.     engine.say(mark)
  39.     engine.say('.')
  40.     engine.runAndWait()
  41.     #input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement