예제 #1
0
def get(word):
    try:
        if word.rfind(r'小时') == -1:
            hour = 0
            # min = cn2dig(min_key)
        else:
            hour_key = word[0:word.rfind(r'小时')]
            word = word[word.rfind(r'小时') + 2:]
            if hour_key == "半":
                hour = 0.5
            else:
                hour = cn2dig(hour_key)

        if word.rfind(r'分钟') == -1:
            min = 0
        else:
            min_key = word[0:word.rfind(r'分钟')]
            word = word[word.rfind(r'分钟') + 2:]
            min = cn2dig(min_key)

        if word.rfind(r'秒') == -1:
            min = 0
        else:
            sec_key = word[0:word.rfind(r'秒')]
            sec = cn2dig(sec_key)

        print(hour, ' ', min, ' ', sec, '?')

        set_reminder(hour, min, sec)
    except:
        speak_api.say('我听不清,你能再说一遍吗')
예제 #2
0
def watch_mail(first_index):
    server = poplib.POP3_SSL(pop_server, '995')
    # print(server.getwelcome().decode('utf-8'))
    server.user(email)
    server.pass_(passwd)

    # 返回所有邮件编号
    resp, mails, octets = server.list()
    index = len(mails)
    # print(index)
    if first_index == index:
        # print("no email")
        server.quit()
        t = Timer(20, watch_mail(first_index))
        t.start()
        print("watch_email", len(mails))
    else:
        print("new email!",
              time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
        path = "./resource/reminder.wav"
        os.system('play ' + path)
        resp, lines, octets = server.retr(index)
        msg_content = b'\r\n'.join(lines).decode('utf-8')

        # 把邮件内容解析为Massage对象,用来解析邮件
        msg = Parser().parsestr(msg_content)
        res = print_info(msg)
        #这里是邮件的全部内容👇
        speak_api.say("您有一封新邮件:" + res)

        server.quit()
        t = Timer(20, watch_mail(index))
        t.start()
def get(word):
    key = re.search(r'播放.*', word).group(0)
    key = key[2:].replace('。', '')
    print(key, '?')
    speak_api.say('请稍等!')
    qqmusic = QQ_Music()
    music_list = qqmusic.get_music_list(key)
    songname = qqmusic.download(music_list[0])

    play_mp3(songname)
예제 #4
0
def talk(word):
    print(word)
    reply = settedAnswer.getAnswer(word)
    if not reply == '':
        speak_api.say(reply)
    elif '今天天气' in word:
        reply = weather.moji()
        speak_api.say(reply)
    else:
        global curTime
        curTime = datetime.datetime.now()
        changeConfidence()
        eg_question = {'text': word, 'confidence': confidence[confidenceLevel]}
        reply = turing.chat(eg_question)
        speak_api.say(reply)
def play_mp3(songname):
    path = "./temp/music/" + songname
    try:
        os.system('play ' + path + '.wav')
    except:
        speak_api.say('对不起,没有找到这首歌')
예제 #6
0
def cancel():
    stop()
    speak_api.say('好的')