Assistant-Java

Goal

A simple client - demo project for the Google Assistant SDK.

This project was built and tested on a Mac.

Version

This README file is written for the latest version. Checkout the project at the desired version if you want to get the associated README.

Configuration

The project use TypeSafe config for the configuration. The main configuration file is src/main/resources/reference.conf

The project use slf4j and log4j2 for logging. You can configure the logger with the log4j2.xml file in the resources folder.

To authenticate the requests to API, the Google Assistant SDK use the oAuth2 protocol. As specified on this page, you must generate a client Id and a client secret for the application. Next you must provide theses values (id and secret) in the reference.conf file.

Since the alpha2 version of the SDK, the API must register a device model and a device instance to use the SDK. See the documentation for more information here. The API handles this registration but you must provide in the reference.conf the id of the project you created during the previous step (to get your oAuth2 credentials). Set this value in the projectId field under deviceRegister in the reference.conf file.

The project use generated bindings (package com.google.assistant.embedded.v1alpha2) from Google Apis (repository in References / Links section). If you want to update theses files, you can follow this guide

Audio / Text - Input / Output

In the reference.conf file, you can choose if you want to make your request with your voice or by entering text (parameter inputMode). You can also choose if you want to play the response in audio with the outputAudio parameter.

Usage

The first time you start the application, you must authorize the application via the oAuth2 protocol. You must copy and paste the authorization code from your browser in your terminal.

The application will register a device model and a device instance with your project id (see the configuration part if you haven't set your project id). This information will be persisted in the device_model.json and device_instance.json files.

Next you can talk and hit enter to send a request to the API. You will receive a response and send another request if you want.

The application will store your oAuth2 credentials in a file so you will not have to authorize the application each time your run it.

References / Links

Feel free to give me some feedback or ask questions if you have any.

Youtube Demo Video

Youtube Video Demo