Skip to content
Voice Interface Driver for Google Assistant
Python C++ Shell Makefile Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
tools build: host build script Jun 28, 2019

Google Assistant SDK for devices - C++


This project is officially supported on Ubuntu 14.04. Other Linux distributions may be able to run this sample.

Refer to the Assistant SDK documentation for more information.

Setup instructions

Clean Project

If you have not setup this project before, you can skip this step.

sudo apt-get purge libc-ares-dev  #
sudo apt-get purge libprotobuf-dev libprotoc-dev
sudo rm -rf /usr/local/bin/grpc_* /usr/local/bin/protoc \
    /usr/local/include/google/protobuf/ /usr/local/include/grpc/ /usr/local/include/grpc++/ \
    /usr/local/lib/libproto* /usr/local/lib/libgpr* /usr/local/lib/libgrpc* \
    /usr/local/lib/pkgconfig/protobuf* /usr/local/lib/pkgconfig/grpc* \

Build Project

  1. Clone this project
git clone
cd assistant-sdk-cpp
export PROJECT_PATH=$(pwd)
  1. Install dependencies
sudo apt-get install autoconf automake libtool build-essential curl unzip pkg-config
sudo apt-get install libasound2-dev  # For ALSA sound output
sudo apt-get install libcurl4-openssl-dev # CURL development library
  1. Build Protocol Buffer, gRPC, and Google APIs
git clone -b $(curl -L

git submodule update --init

cd third_party/protobuf
./ && ./configure && make
sudo make install
sudo ldconfig

export LDFLAGS="$LDFLAGS -lm"
make clean
sudo make install
sudo ldconfig

git clone
cd googleapis/
git checkout 980cdfa
make LANGUAGE=cpp
  1. Make sure you setup environment variable $GOOGLEAPIS_GENS_PATH
export GOOGLEAPIS_GENS_PATH=${PROJECT_PATH}/googleapis/gens
  1. Build this project
make run_assistant
  1. Get credentials file. It must be an end-user's credentials.
  • Go to the Actions Console and register your device model, following these instructions
  • Move it in this folder and rename it to client_secret.json
  • run in this folder. It will create the file credentials.json.
  1. Start one of the run_assistant samples:
./run_assistant_file --input ./resources/weather_in_mountain_view.raw --output ./response.wav --credentials ./credentials.json
aplay ./response.wav --rate=16000 --format=S16_LE

On a Linux workstation, you can alternatively use ALSA for audio input:

./run_assistant_audio --credentials ./credentials.json

You can use a text-based query instead of audio. This allows you to continually enter text queries to the Assistant.

./run_assistant_text --credentials ./credentials.json

This takes input from cin, so you can send data to the program when it starts.

echo "what time is it" | ./run_assistant_text --credentials ./credentials.json

To change the locale, include a locale parameter:

echo "Bonjour" | ./run_assistant_text --credentials ./credentials.json --locale "fr-FR"

Default Assistant gRPC API endpoint is If you want to test with a custom Assistant gRPC API endpoint, you can pass --api_endpoint CUSTOM_API_ENDPOINT.

Enabling screen output

To get a visual output from the Assistant, provide a command to be run alongside every step of the conversation. It will execute that command along along with a provided argument of a temporary HTML file.

echo "what time is it" | ./run_assistant_text --credentials ./credentials.json --html_out google-chrome

After you enter text, it will run google-chrome /tmp/google-assistant-cpp-screen-out.html.

If you prefer a different program, use that argument instead.

You can’t perform that action at this time.