-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline.py
71 lines (65 loc) · 2.23 KB
/
pipeline.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import listener
import speechToText
import textToCode
import spotify
import os
clear = lambda: os.system('clear')
clear()
def main():
try:
listener.listen()
prompt = speechToText.transcribe()
clear()
print("%s" % prompt[1:])
command = textToCode.transcribe(prompt)
state = ""
success = True
if command == "There was an error transcribing to code.":
print(command)
elif command[0] == "SPOTIFY_ARTIST":
spotify.play_request(name=command[1][0], commandType="artist")
state = spotify.get_state()
elif command[0] == "SPOTIFY_ALBUM":
spotify.play_request(name=command[1][0], commandType="album")
state = spotify.get_state()
elif command[0] == "SPOTIFY_SONG":
query = ""
if type(command[1]) is list:
for arg in command[1]:
query += arg + "+"
else:
query = command[1]
spotify.play_request(name=query, commandType="track")
state = spotify.get_state()
elif command[0] == "SPOTIFY_PLAYLIST":
spotify.play_request(name=command[1][0], commandType="artist")
state = spotify.get_state()
elif command[0] == "SPOTIFY_START_PLAYBACK":
spotify.resume()
state = spotify.get_state()
elif command[0] == "SPOTIFY_PAUSE_PLAYBACK":
spotify.pause()
state = spotify.get_state()
elif command[0] == "SPOTIFY_NEXT":
spotify.next_track()
state = spotify.get_state()
elif command[0] == "SPOTIFY_PREVIOUS":
spotify.previous_track()
state = spotify.get_state()
# Possibly upcoming features
elif command[0] == "NETFLIX_MOVIE":
pass
elif command[0] == "NETFLIX_TV":
pass
elif command[0] == "BEDROOM_LIGHTS_ON":
state = "Lights on!"
elif command[0] == "BEDROOM_LIGHTS_OFF":
state = "Lights off!"
elif command[0] == "WEATHER_WIDGET":
pass
clear()
print(state)
return success
except Exception as e:
# print("Exception: " + str(e))
return False