Skip to content

IntelligentRoboticsLabs/gb_dialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GB-dialog

GB-dialog simplifies the task of developing actions or behaviors related to dialogue.

GB-dialog contains the library DialogInterface from which we will inherit to develop our dialogue actions. Each action would be specific to an intent (Dialogflow concepts). The library offers methods to do speech-to-text tasks through Google Speech sevice and methods to do Natural Language Processing tasks through Dialogflow, using the ROS package dialogflow_ros (official package, our custom dialogflow_ros). The library also offers a method to do text-to-speech through the package sound_play.

Installing

Install requirements

If you don't have vcs tool, install it with:

sudo apt-get install python3-vcstool wget libgst-dev libgst7 libgstreamer1.0-* libgstreamer-plugins-base1.0-dev

Clone dialog packages

First of all, clone all the relevant pacakges for dialog. Create a folder dialog and clone all required packages using the tool vcs from vcstool:

cd <workspace>/src
mkdir dialog
cd dialog
wget https://raw.githubusercontent.com/IntelligentRoboticsLabs/gb_dialog/ros2/gb_dialog.repos
vcs import < gb_dialog.repos

cd <workspace>
rosdep install --from-paths src --ignore-src -r -y

and build the workspace.

Setup

Original instructions are in this README. Use it as reference:

Install the requirements for dialogflow_ros:

sudo apt-get install portaudio19-dev
cd <workspace>/src/dialog/dialogflow_ros2
pip3 install -r requirements.txt

Google Cloud and DialogFlow Setup

  1. Go to Google Cloud Console.
  2. Create a new project.
  3. Go to the Kick Setup.
  4. Enable API.
  5. Create Service Account. Put on the role of owner.
  6. Click on your service account. Create key & download the JSON File. Rename and move it t your HOME as ~/df_api.json.
  7. Go to DialogFlow Console.
  8. Create new Agent & select the project.
  9. Edit dialogflow_ros/config/param.yaml and write down your project id. You can find it in the DialogFlow Console, clicking in the gear icon.
  10. Add export GOOGLE_APPLICATION_CREDENTIALS='/home/<user>/df_api.json' to your .bashrc and change user.

Use

Below is an example of using the GB-dialog library (example file. First of all we define our new class that inherits from DialogInterface. Then, I must use the function registerCallback to define the handler of the DialogFlow response. You can indicate a specific intent on each callback to receive the DialogFlow responses in differents callbacks, or not to receive all results from DialogFlow in the same callback, up to you!

class ExampleDF: public DialogInterface
{
  public:
    ExampleDF(): nh_()
    {
      this->registerCallback(std::bind(&ExampleDF::noIntentCB, this, ph::_1));
      this->registerCallback(
        std::bind(&ExampleDF::welcomeIntentCB, this, ph::_1),
        "Default Welcome Intent");
    }
...
};

When we have our class instantiated we can use the methods speak or listen. Both methods are syncronous

gb_dialog::DialogInterfaceTest di();
di.speak("Hello world!")
gb_dialog::DialogInterfaceTest di();
di.listen();

Tests

Compile and execute the test

ros2 launch gb_dialog gb_dialog_services_soundplay.launch.py
ros2 run gb_dialog example_df_node

And talk :)

Creating a virtualenv for install Python modules

If you have dependencies issues when you installed the above requirements
Create a virtualenv virtualenv venv --system-site-packages
Activate the virtual env source venv/bin/activate
Install the dependencies pip install -r [__gb_dialog_Path__]/dialogflow_ros/dialogflow_ros/requirements.txt

Remind activate the virtualenv in each shell where you want use dialogflow_ros

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published