-
Notifications
You must be signed in to change notification settings - Fork 0
/
SkillListener.py
51 lines (36 loc) · 1.48 KB
/
SkillListener.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
import logging
import configparser
import rhasspy_datetime
from rhasspyhermes.nlu import NluIntent
from rhasspyhermes_app import EndSession, HermesApp
from rhasspy_weather import weather
_LOGGER = logging.getLogger("SkillListener")
config = configparser.ConfigParser()
config.read('config.ini')
client = config["mqtt"]["client"]
server = config["mqtt"]["server"]
port = config["mqtt"].getint("port")
user = config["mqtt"]["user"]
password = config["mqtt"]["password"]
app = HermesApp(client, host=server, port=port, username=user, password=password)
@app.on_intent("GetTime")
async def get_time(intent: NluIntent):
"""Tell the time."""
return EndSession(rhasspy_datetime.get_time(config_path=config["rhasspy_datetime"]["config"]))
@app.on_intent("GetDate")
async def get_date(intent: NluIntent):
"""Tell the date."""
return EndSession(rhasspy_datetime.get_date(config_path=config["rhasspy_datetime"]["config"]))
@app.on_intent("GetWeekday")
async def get_date(intent: NluIntent):
"""Tell the weekday."""
return EndSession(rhasspy_datetime.get_weekday(config_path=config["rhasspy_datetime"]["config"]))
@app.on_intent("GetWeatherForecast")
@app.on_intent("GetWeatherForecastTemperature")
@app.on_intent("GetWeatherForecastCondition")
@app.on_intent("GetWeatherForecastItem")
async def get_weather(intent: NluIntent):
"""Get weather"""
forecast = weather.get_weather_forecast(intent, config_path=config["rhasspy_weather"]["config"])
return EndSession(forecast)
app.run()