def main(): title = 'BANCO AA' easygui.msgbox('Bienvenido al BANCO AA', title, 'Next', image="logo.jpg") print("\nBienvenido al BANCO AA\n") fieldValues = easygui.multenterbox("Ingresa tu numero de cuenta:",title, ["Numero de cuenta"]) print("Ingresa tu numero de cuenta:\n") numero_cuenta = int(input_data.get_value()) if(numero_cuenta == Cuentas.cuenta1["numero_cuenta"]): print("Tu numero de cuenta es: ") print(Cuentas.cuenta1["numero_cuenta"],"\n") print("Tu saldo es: ") print("$",Cuentas.cuenta1["saldo"],"\n") print("Tu interes es: ") print(Cuentas.cuenta1["interes"],"%\n") reitengro(cuenta= Cuentas.cuenta1) elif (numero_cuenta == Cuentas.cuenta2["numero_cuenta"]): print("Tu numero de cuenta es: ") print(Cuentas.cuenta2["numero_cuenta"],"\n") print("Tu saldo es: ") print("$",Cuentas.cuenta2["saldo"],"\n") print("Tu interes es: ") print(Cuentas.cuenta2["interes"],"%\n") reitengro(cuenta= Cuentas.cuenta2) else: print("Cuenta no disponible")
def reitengro(cuenta): print("Selecciona una accion: \n") print("1- Retirar") print("2- Salir") choice = input_data.get_value() if (choice == "1"): print("ingrese una cantidad: \n") retiro = input_data.get_value() retiro = int(retiro) if (retiro < cuenta["saldo"]): print("Tu transaccion fue exitosa") cuenta["saldo"] = cuenta["saldo"] - retiro else: print("No tienes saldo suficiente") elif(choice == "2"): sys.exit()
def main(): ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN) request = ai.text_request() request.lang = 'en' # optional, default value equal 'en' request.session_id = "<chatbot-b4841>" if int(choice) == 0: print("\n Say something to the Chatbot! \n") request.query = input_data.get_value() if int(choice) == 1: r = sr.Recognizer() with sr.Microphone(device_index=1) as source: audio = r.adjust_for_ambient_noise(source) print("\nSay something!") audio = r.listen(source) try: # for testing purposes, we're just using the default API key # to use another API key, use `r.recognize_google(audio, key="GOOGLE_SPEECH_RECOGNITION_API_KEY")` # instead of `r.recognize_google(audio)` voice = r.recognize_google(audio) print("\nYou said: " + voice) request.query = voice except sr.UnknownValueError: pass print("Google Speech Recognition could not understand audio") except sr.RequestError as e: print( "\nCould not request results from Google Speech Recognition service; {0}" .format(e)) response = request.getresponse() data = response.read().decode("utf-8") data = json.loads(data) with open('chatbot.json', 'w') as outfile: json.dump(data, outfile) try: data = data['result']['fulfillment']['speech'] except: data = "Dont be shy!" data2 = "\nChatbot: " + data print(data2) engine.say(data) engine.runAndWait() if data == "Good bye!": sys.exit() elif data == "Turning on the red light": ArduinoSerial.write('0'.encode()) elif data == "Turning on the blue light": ArduinoSerial.write('1'.encode()) elif data == "Turning off the red light": ArduinoSerial.write('2'.encode()) elif data == "Turning off the blue light": ArduinoSerial.write('3'.encode())
pass print("Google Speech Recognition could not understand audio") except sr.RequestError as e: print( "\nCould not request results from Google Speech Recognition service; {0}" .format(e)) response = request.getresponse() data = response.read().decode("utf-8") data = json.loads(data) with open('chatbot.json', 'w') as outfile: json.dump(data, outfile) try: data = data['result']['fulfillment']['speech'] except: data = "Dont be shy!" data2 = "\nChatbot: " + data print(data2) engine.say(data) engine.runAndWait() if __name__ == '__main__': print("\n Choose text or voice \n") print("0- Text\n1- Voice") choice = input_data.get_value() while True: main()