コード例 #1
0
def confirm_user_response(phrase, response, function):
    gtts.speak('is this correct?')
    text, audio = assistant.recognize()

    if text == 'yes':
        gtts.speak(phrase)
        gtts.speak(response)
        return response
    elif text == 'no':
        try_again(function)
コード例 #2
0
def try_again(function):
    status_ui = aiy.voicehat.get_status_ui()
    gtts.speak('would you like to try again?')
    text, audio = assistant.recognize()

    if text == 'yes':
        function()
    else:
        gtts.speak('ok. aborting email service')
        status_ui.status('ready')
        can_start_conversation = True
コード例 #3
0
def set_recipients():
    gtts.speak('who should i send the email to?')
    print('Listening ...')
    recipient, audio = assistant.recognize()
    
    if recipient is not None:
        gtts.speak('You said ' + recipient)
        print('You said, "', recipient, '"')
        
        confirm_user_response('ok email will be sent to', recipient, set_recipients)
    else:
        print('i did not hear you')
        gtts.speak('i did not hear you')
        
        try_again(set_recipients)    
コード例 #4
0
def confirm_information():
    status_ui = aiy.voicehat.get_status_ui()
    recipient = set_recipients()
    
    gtts.speak('let\'s confirm. you would like audio.wav sent to ' + recipient + '. is this correct?')
    
    text, audio = assistant.recognize()
    
    if text == 'yes':
        gtts.speak('ok sending email')
        send_files(recipient, ['audio.wav'])
    elif text == 'no':
        gtts.speak('ok. aborting email service')
        status_ui.status('ready')
        can_start_conversation = True