0

I'm using android studio and I need to emulate a conversation with Pepper emulator by using its dialog view. I'm using the following code to connect to pepper emulator and to talk with him:

import qi
import argparse
import sys
import time
import os



def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--pip", type=str, default=os.environ['PEPPER_IP'],
                    help="Robot IP address.  On robot or Local Naoqi: use '127.0.0.1'.")
    parser.add_argument("--pport", type=int, default=9559,
                    help="Naoqi port number")
    parser.add_argument("--sentence", type=str, default="hello",
                    help="Sentence to say")
    parser.add_argument("--language", type=str, default="English",
                    help="language")
    parser.add_argument("--speed", type=int, default=100,
                    help="speed")

    args = parser.parse_args()
    pip = args.pip
    pport = args.pport
    strsay = args.sentence
    language = args.language
    speed = args.speed

    #Starting application
    try:
       connection_url = "tcp://" + pip + ":" + str(pport)
       app = qi.Application(["Say", "--qi-url=" + connection_url ])
    except RuntimeError:
       print ("Can't connect to Naoqi at ip \"" + pip + "\" on port " + str(pport) +".\n"
           "Please check your script arguments. Run with -h option for help.")
       sys.exit(1)

     app.start()
     session = app.session

     tts_service = session.service("ALTextToSpeech")

     tts_service.setLanguage(language)
     tts_service.setVolume(1.0)
     tts_service.setParameter("speed", speed)
     tts_service.say(strsay)
     print "  -- Say: "+strsay

     tts_service.say("what's your name?")
     print " --Say: "+ "what's your name?"


     person = raw_input('name: ') #get input from the keyboard using terminal, but I need to take input from dialog view of pepper emulator

     tts_service.say("Hi: "+person)
     print " --Say: "+ "Hi "+ person

if __name__ == "__main__":
     main()

In the code there is tts_service.say("Hi: "+person) that it is used to show the conversation on the dialog view. Is there something similar to get information form the dialog view? In the conversation I used the function raw_input but this takes input from the terminal and not from the dialog view.

Gold
  • 179
  • 2
  • 11

1 Answers1

0

Starting from NAOqi 2.9, the dialogues are to be written using the Chat and QiChatbot APIs. They are connected with the dialog view, so you will be able to use it to emulate speech input.

Check out this tutorial on how to write a simple dialogue in an Android-based application, instead of Python. There is a sample project you can clone to try it out directly.

Victor Paléologue
  • 2,025
  • 1
  • 17
  • 27