-
Notifications
You must be signed in to change notification settings - Fork 47
/
tools.py
54 lines (39 loc) · 1.48 KB
/
tools.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
import python_weather
import asyncio
import assist
from icrawler.builtin import GoogleImageCrawler
import os
import spot
async def get_weather(city_name):
async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
weather = await client.get(city_name)
return weather
def search(query):
google_Crawler = GoogleImageCrawler(storage = {"root_dir": r'./images'})
google_Crawler.crawl(keyword = query, max_num = 1)
def parse_command(command):
if "weather" in command:
weather_description = asyncio.run(get_weather("Chicago"))
query = "System information: " + str(weather_description)
print(query)
response = assist.ask_question_memory(query)
done = assist.TTS(response)
if "search" in command:
files = os.listdir("./images")
[os.remove(os.path.join("./images", f))for f in files]
query = command.split("-")[1]
search(query)
if "play" in command:
spot.start_music()
if "pause" in command:
spot.stop_music()
if "skip" in command:
spot.skip_to_next()
if "previous" in command:
spot.skip_to_previous()
if "spotify" in command:
spotify_info = spot.get_current_playing_info()
query = "System information: " + str(spotify_info)
print(query)
response = assist.ask_question_memory(query)
done = assist.TTS(response)