TSA-demo/TSA_voice_assistant/raspberry_voice_assistant.py [265:323]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        return "none"

def decode(data):
    decoded_data = base64.b64decode(data)
    decompressed_data = zlib.decompress(decoded_data, 16+zlib.MAX_WBITS)
    return json.loads(decompressed_data)

def get_voiceid():
    lexv2_model = session.client('lexv2-models')
    bot_alias = lexv2_model.describe_bot_alias(
        botAliasId = bot_alias_id,
        botId = bot_id
    )
    bot_locale = lexv2_model.describe_bot_locale(
        botId = bot_id,
        botVersion = bot_alias['botVersion'],
        localeId = 'en_US'
    )
    return bot_locale['voiceSettings']['voiceId']

def main():
    print("starting")
    #word()
    #print ('bot: ', bot)
    print("going to record")
    session_id = str(uuid.uuid4())
    #while 1:
    while iot_sub.launchlextt:
        try:
            if platform_sys != 'Darwin':
                        set_color(COLORS_RGB[KEYWORDS_COLOR['porcupine']])
            print('iot_sub.launchlextt2: ', iot_sub.launchlextt)
            recording = record_phrase()
            if not iot_sub.launchlextt:
                print('stop in middle')
                break
            response = call_lexv2(session_id, bytes(recording))
            if response == 'none':
                break    
            play_audio(response['audioStream'])
            session_state = decode(response['sessionState'])
            dialog_action = session_state['dialogAction']['type']
            state = session_state['intent']['state']
            if dialog_action == 'Close' and state == 'Fulfilled':
                break
        except Exception as e:
            print(e)

if __name__ == "__main__":
    bot = True
    global launchlex 
    launchlex = False
    #sub = mqtt_subscribe()
    intro = 0
    close = 0
    if platform_sys !='Darwin':
        color_start()
    while bot:
        pass
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



TSA-demo/TSA_voice_assistant/raspberry_voice_assistant_local.py [293:351]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        return "none"

def decode(data):
    decoded_data = base64.b64decode(data)
    decompressed_data = zlib.decompress(decoded_data, 16+zlib.MAX_WBITS)
    return json.loads(decompressed_data)

def get_voiceid():
    lexv2_model = session.client('lexv2-models')
    bot_alias = lexv2_model.describe_bot_alias(
        botAliasId = bot_alias_id,
        botId = bot_id
    )
    bot_locale = lexv2_model.describe_bot_locale(
        botId = bot_id,
        botVersion = bot_alias['botVersion'],
        localeId = 'en_US'
    )
    return bot_locale['voiceSettings']['voiceId']

def main():
    print("starting")
    #word()
    #print ('bot: ', bot)
    print("going to record")
    session_id = str(uuid.uuid4())
    #while 1:
    while iot_sub.launchlextt:
        try:
            if platform_sys != 'Darwin':
                        set_color(COLORS_RGB[KEYWORDS_COLOR['porcupine']])
            print('iot_sub.launchlextt2: ', iot_sub.launchlextt)
            recording = record_phrase()
            if not iot_sub.launchlextt:
                print('stop in middle')
                break
            response = call_lexv2(session_id, bytes(recording))
            if response == 'none':
                break    
            play_audio(response['audioStream'])
            session_state = decode(response['sessionState'])
            dialog_action = session_state['dialogAction']['type']
            state = session_state['intent']['state']
            if dialog_action == 'Close' and state == 'Fulfilled':
                break
        except Exception as e:
            print(e)

if __name__ == "__main__":
    bot = True
    global launchlex 
    launchlex = False
    #sub = mqtt_subscribe()
    intro = 0
    close = 0
    if platform_sys !='Darwin':
        color_start()
    while bot:
        pass
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



