コード例 #1
0
ファイル: Volume.py プロジェクト: xueshanlinghu/wukong-robot
 def handle(self, text, parsed):
     if not self.player:
         self.player = MusicPlayer([], self)
     if self.nlu.hasIntent(parsed, "CHANGE_VOL"):
         slots = self.nlu.getSlots(parsed, "CHANGE_VOL")
         for slot in slots:
             if slot["name"] == "user_d":
                 word = self.nlu.getSlotWords(parsed, "CHANGE_VOL",
                                              "user_d")[0]
                 if word == "--HIGHER--":
                     self.player.turnUp()
                     self.say("好的", cache=True)
                 else:
                     self.player.turnDown()
                     self.say("好的", cache=True)
                 return
             elif slot["name"] == "user_vd":
                 word = self.nlu.getSlotWords(parsed, "CHANGE_VOL",
                                              "user_vd")[0]
                 if word == "--LOUDER--":
                     self.player.turnUp()
                     self.say("好的", cache=True)
                 else:
                     self.player.turnDown()
                     self.say("好的", cache=True)
コード例 #2
0
 def handle(self, text, parsed):
     try:
         if not self.player:
             self.player = MusicPlayer([], self)
         if any(word in text for word in ['大']):
             self.player.turnUp()
         elif any(word in text for word in ['小']):
             self.player.turnDown()
         else:
             self.say('请下达调整音量的指令。', cache=True)
     except Exception as e:
         print(e)
コード例 #3
0
ファイル: Volume.py プロジェクト: xueshanlinghu/wukong-robot
class Plugin(AbstractPlugin):
    def __init__(self, con):
        super(Plugin, self).__init__(con)
        self.player = None

    def handle(self, text, parsed):
        if not self.player:
            self.player = MusicPlayer([], self)
        if self.nlu.hasIntent(parsed, "CHANGE_VOL"):
            slots = self.nlu.getSlots(parsed, "CHANGE_VOL")
            for slot in slots:
                if slot["name"] == "user_d":
                    word = self.nlu.getSlotWords(parsed, "CHANGE_VOL",
                                                 "user_d")[0]
                    if word == "--HIGHER--":
                        self.player.turnUp()
                        self.say("好的", cache=True)
                    else:
                        self.player.turnDown()
                        self.say("好的", cache=True)
                    return
                elif slot["name"] == "user_vd":
                    word = self.nlu.getSlotWords(parsed, "CHANGE_VOL",
                                                 "user_vd")[0]
                    if word == "--LOUDER--":
                        self.player.turnUp()
                        self.say("好的", cache=True)
                    else:
                        self.player.turnDown()
                        self.say("好的", cache=True)

    def isValid(self, text, parsed):
        return self.nlu.hasIntent(parsed, "CHANGE_VOL")
コード例 #4
0
 def init_music_player(self):
     self.song_list = self.get_song_list(config.get('/LocalPlayer/path'))
     if self.song_list == None:
         logger.error('{} 插件配置有误'.format(self.SLUG))
     logger.info('本地音乐列表:{}'.format(self.song_list))
     print('本地音乐列表:{}'.format(self.song_list))
     return MusicPlayer(self.song_list, self)
コード例 #5
0
class Plugin(AbstractPlugin):
    def __init__(self, con):
        super(Plugin, self).__init__(con)
        self.player = None

    def handle(self, text, parsed):
        try:
            if not self.player:
                self.player = MusicPlayer([], self)
            if any(word in text for word in ['大']):
                self.player.turnUp()
            elif any(word in text for word in ['小']):
                self.player.turnDown()
            else:
                self.say('请下达调整音量的指令。', cache=True)
        except Exception as e:
            print(e)

    def isValid(self, text, parsed):
        return any(word in text for word in ['声音', '音量'])
コード例 #6
0
 def init_music_player(self):
     self.song_list = self.get_song_list(config.get("/LocalPlayer/path"))
     if self.song_list == None:
         logger.error("{} 插件配置有误".format(self.SLUG))
     logger.info("本地音乐列表:{}".format(self.song_list))
     return MusicPlayer(self.song_list, self)