Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction

The Dialogflow service allows using the Google Dialogflow platform within your application. Dialogflow is used to translate human speech into intents (intent recognition). In other words, not only does it (try to) convert an audio stream into readable text, it also processes this text into an intent (possibly with some additional parameters). For example, an audio stream can translate to the string "I am 15 years old", which is, in turn, converted to the intent 'answer_age' with the parameter 'age = 15'.

Dependencies

No external services from the local infrastructure are required to run this service, however, you need to have the following devices running, if testing locally; computer-robot, computer-speaker, and computer-microphone.

Parameters

In order to run this service, the following parameters are needed:

  1. dialogflow_agent_id

  2. dialogflow_key_file

If you do not possess the mentioned parameters, please refer to the section Initialisation → Setting up Dialogflow.

Output

The output solely depends on your project and the set-up of your intents and entities of the Dialogflow agent.

Initialisation

Setting up Dialogflow

Our service communicates with a Dialogflow agent to achieve its intended purpose, and it does so by using a project ID and a key file. However, if you happen to have them, you may skip the following steps:

  1. Create a Dialogflow agent by clicking the following link: https://dialogflow.cloud.google.com

  2. Use the ‘Create Agent' button at the left top to start your first project. Press the settings icon next to your agent's name at the left top to see the Project ID.

  3. Follow the steps here to retrieve your private key file in JSON format.

Using Dialogflow

In order to use our service for your purposes,

Example

Setting up intents

The main items of interest are the Intents and the Entities. An intent is something you want to recognise from an end-user; here we will show you an example of an intent that is aimed at recognising someone’s name.

When creating an intent, you can name it anything you like; we go with 'answer_name' here. Below 'Action and parameters', you should give the name of the intent that will actually be used in your program. Here, we also make that 'answer_name'. Moreover, it is useful to set a context for the intent. A context is set by the requester in order to indicate that we only want to recognise this specific intent and not another one. Usually, in a social robotics application, the kind of answer we want to get is known. We match the name of the (input)context with the name of the intent and thus make it 'answer_name' as well. By default, Dialogflow makes the context 'stick' for 5 answers; we can fix this by changing the 5 (at the output context) to a 0. Now we arrive at the most important aspect of the intent: the training phrases. Here you can give the kinds of input strings you would expect; from these Dialogflow learns the model it will eventually use. You can make a part of the phrase into a parameter by double-clicking on the relevant word and selecting the appropriate entity from the list. It will then automatically appear below ‘Action and parameters' as well; the ‘parameter name’ there will be passed in the result (we use 'name’ here). The system has many built-in entities (like 'given name'), but you can define your own entities as well (even through importing CSV files). Our complete intent example thus looks like this (note: using sys.given-name is usually preferred):

Running an example

We have provided a file with the name “speech_recognition_example.py" for the purpose of demonstration. If you wish to test this locally, ensure the following points are taken into consideration:

  1. You have the correct agent name and keyfile(path) as parameters for an instance of the class Example in the example file

  2. You have the Dialogflow service running, via the command “docker-compose up dialogflow”, and you have the relevant local drivers running, i.e computer-robot.jar and computer-speakers.jar.

Events

Events that the service creates and can have listeners

Limitations

There is a rare bug where sometimes Dialogflow will suddenly only respond with ‘UNAUTHENTICATED’ errors. Restarting Docker and/or your entire machine seems to be the only way to resolve this.

  • No labels