def getskills(self, intent, text, tok): if intent == 'clock': clock.start(tok) elif intent == 'camera': camera.start(tok) elif intent == 'smarthome': smarthome.start(tok) elif intent == 'weather': weather.start(tok) elif intent == 'music': music.start(tok) elif intent == 'mail': mail.start(tok) elif intent == 'joke': joke.start(tok) elif intent == 'news': news.start(tok) elif intent == 'tuling': tuling.start(text, tok) elif intent == 'snowboytrain': snowboytrain.start(tok) elif intent == 'raspberrypi-gpio': raspberrypigpio.start(tok) elif intent == 'respeaker': speaker.speak() elif intent == 'no': sconvenstation() elif intent == 'reintent': intent = nlp.do_intent(text, tok) s.getskills(intent, text, tok)
def snowboytrain(self, tok): snowboytrain.start(tok)
def do_intent(text, tok): sm = hass() m = xlMusic() services = { 'musicurl_get': 'method=baidu.ting.song.play&songid=', 'search': 'method=baidu.ting.search.catalogSug&query=', 'hot': 'method=baidu.ting.song.getRecommandSongList&song_id=877578&num=12' } if text != None: if '闹钟' in text: clock.start(tok) elif '打开' in text: sm.cortol('turn_on', text[6:-1], tok) elif '关闭' in text: sm.cortol('turn_off', text[6:-1], tok) elif '获取' in text: if '传感器' in text or '温度' in text: sm.sensor('sensor', text[6:-1], tok) elif '湿度' in text: sm.sensor('sensor', text[6:-1], tok) else: sm.sensor('switch', text[6:-1], tok) elif '天气' in text: weather.main(tok) elif '重新说' in text or '重复' in text: speaker.speak() elif '翻译' in text: ts.main(tok) elif '搜索' in text: tuling.main(text, tok) elif '闲聊' in text: tuling.main(text, tok) elif '怎么走' in text: maps.start(tok) elif '酒店' in text: tuling.main(text, tok) elif '旅游' in text: tuling.main(text, tok) elif '新闻' in text: news.start(tok) elif '拍照' in text: camera.start(tok) elif '邮件' in text or '邮件助手' in text: mail.start(tok) elif '快递' in text: express.start(tok) elif '笑话' in text: joke.main(tok) elif '训练' in text: snowboytrain.start(tok) elif '播放' in text: if '音乐' in text: m.sui_ji(services, tok) else: songname = text[2:-1] m.sou_suo(services, songname, tok) elif '我想听' in text: if '音乐' in text: m.sui_ji(services, tok) else: songname = text[3:-1] m.sou_suo(services, songname, tok) else: tuling.start(text, tok) else: speaker.speacilrecorder()