-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeecher.py
More file actions
29 lines (23 loc) · 845 Bytes
/
speecher.py
File metadata and controls
29 lines (23 loc) · 845 Bytes
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
import os
import threading
def getPhraseToSay(listOfTimes,currentTime):
for key in listOfTimes:
#print("key=" + key)
#print("curTime=" + str(currentTime))
if key == str(currentTime):
return listOfTimes.pop(key,None)
def speak(listOfTimes, currentTime):
phrase = getPhraseToSay(listOfTimes, currentTime)
if phrase:
print("Speaking:" + phrase["phrase"])
t = threading.Thread(target=worker, args=(phrase,))
t.start()
def worker(phrase):
speakingPhrase = phrase["phrase"]
print "SpeakingPhrase:" + str(phrase)
if "parms" in phrase:
os.system("espeak " + phrase["parms"] + " \"" + speakingPhrase + "\"")
elif "file" in phrase:
os.system("aplay " + phrase["file"] )
else:
os.system("espeak " + "\"" + speakingPhrase + "\"")