Dialogflow — Detect intent with streaming from mic and output as streaming into speaker — Raspberrypi + Typescript

Screenshot from Raspberrypi
  1. Checkout the project from github and start using it, if you are familiar with DialogFlow.
  2. Create a GCM Project in google console.

Go to google console dashboard and create a new Project. I created a project with name `Dialogflow-Test`

Now click on the NEW PROJECT button and create a new project.

2. Generate `key.json`for the above created project

From the left side menu of dashboard page select `IAM & Admin →Service Accounts`. Now select the projected created in above steps. Click on the Create Service Account button.

Create new service account page will appear as follows. Give a name and create it.

Next step is to add Roles to the service accounts. Add 3 roles

  1. Dialogflow API Admin
  2. Dialogflow API Client
  3. Dialogflow API Reader

After selecting these 3 roles, click on continue.

Now click on the CREATE KEY button and create the key as json format. Save the key in your local machine.

Now go to your DialogFlow console and Create an Agent. I created an agent named `Room-Reservation`.

  1. Download the room-booking-agent.zip file.
  2. Click the settings button next to the agent name.
  3. Select the Export and Import tab.
  4. Select Restore From Zip and follow instructions to restore the zip file that you downloaded.

Now to the Speech tab and enable Text to Speech. Also change the voice to en-US-Wavenet-E (or some other language as your choice, but remember the decision, we need to use the name in the program later).

Now clone the repository : https://github.com/princekf/dialogflow-streaming-intent-typescript and follow the steps.

1. cd to the cloned directory
2. yarn install
3. copy the downloaded key json file into the cloned directory.
4. pass the file name as paramter while creating SessionsClient in app.ts
5. this.sessionClient = new dialogflow.v2.SessionsClient({keyFilename : './key.json'});
6. install sox using : sudo apt install sox libsox-fmt-all
7. install sound : sudo apt install libasound2-dev
8. Change project id in app.ts :
const projectId = 'dialogflow-test-101';
9. yarn dev

Now the application is started. Say hello, it will start booking a room for you.

I followed the urls :

  1. https://medium.com/google-cloud/streaming-dialogflow-on-your-desktop-device-raspberry-pi-fe95b70b33a1
  2. https://cloud.google.com/dialogflow/docs/how/detect-intent-stream
  3. https://cloud.google.com/dialogflow/docs/how/detect-intent-tts

Providing simple solutions for complex problems.