<> <> = Overview = This package uses the Google Text-To-Speech (TTS) API to send results to [[https://dialogflow.com/|Dialogflow]], Google's NLP platform. == Installation == There is an install.sh script available in git directory if you wish to use it, however, I will go over the steps one-by-one here. Installing this package requires 3 main steps: cloning the dialogflow repo, setting up your Google cloud project, and setting up Dialogflow. However, we need to install PortAudio so we can use PyAudio to get mic data. {{{ sudo apt-get install portaudio19-dev }}} === Cloning The Repo === Install all the requirements using pip by cloning the Github repo and installing all the packages in `requirements.txt`. {{{ cd ~/catkin_ws/src git clone https://github.com/piraka9011/dialogflow_ros.git cd dialogflow_ros pip install -r requirements.txt }}} === Google Cloud Setup === Follow the instructions [[https://cloud.google.com/speech/docs/quickstart|here]] for configuring your Google Cloud project and installing the SDK for authentication. You will need a google/gmail account. Usage of the Google Cloud SDK requires authentication. This means you require an API key and an activated service account to utilize the APIs. 1. Setup a [[https://cloud.google.com/docs/authentication/getting-started|service account]] 2. Download the service account key as a JSON. 3. Check you have GOOGLE_APPLICATION_CREDENTIALS in your environment. This should be the path to the keys. {{{ export GOOGLE_APPLICATION_CREDENTIALS='/path/to/key' }}} 4. Run the authentication command: {{{ gcloud auth activate-service-account --key-file GOOGLE_APPLICATION_CREDENTIALS }}} === Dialogflow Setup === Follow the steps [[https://dialogflow.com/docs/reference/v2-auth-setup|here]] to setup authentication with Dialogflow. Note the name of your `project-id` and make sure to change that in `config/params.yaml`. == Usage == Follow the steps below to run the package properly. === Configure topics === Go into the `config` directory and change the following parameters in the `params.yaml` file: 1. `results_topic`: (Optional) The topic where your results will be published. 2. `project_id`: The name of your project for the Google Speech node. This is the name of your Google Cloud project when going through the Google Cloud setup. === Launching nodes === To start the Dialogflow nodes, run the following command: {{{ roslaunch dialogflow_ros dialogflow.launch }}} == ROS Nodes == {{{ #!clearsilver CS/NodeAPI node.0 { name = mic_client desc = ROS node receives text from the Google Cloud Speech API and publishes it onto text_topic (see `config/params.yaml`). This is used by the dialogflow_client node. pub { 0.name= text_topic 0.type= std_msgs/String 0.desc= Acquired text from the Google Cloud Speech API. } } node.1 { name = dialogflow_client desc = ROS node that takes text from the `mic_client` node and sends it to Dialogflow for parsing. pub { 1.name= results_topic 1.type= dialogflow_msgs/DialogflowResult 1.desc= Publishes a message with the actions, parameters (python dictionary), and fulfillment text associated with the detected intent as a `std_msgs/String`. } } }}} == Troubleshooting == * If you get an OpenSSL error/InsecurePlatformWarning, run sudo pip install 'requests[security]'. Otherwise make sure you are running Python version 2.7.9+. * If you get any ALSA lib pcm.c ... errors, see [[https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=136974|this thread]]. * Any underrun errors means we need to change chunk size. * If you get a bt_audio_service_open error, run sudo apt-get remove bluez-alsa