Since the launch of the Google Assistant, the internet has been flooded with numerous tips and tricks to get the Assistant working on devices other than the Google Home and the Pixel series smartphones. Google had recently launched the Google Assistant SDK which allows Assistant to be run on basically any platform. So in this post will show you how you can get the Google Assistant running on platforms like Windows, Mac, or Linux.
Get Google Assistant on Windows, Mac, or Linux
- To make this happen, You will need to install this software called “Python“ on your PC. Download its most recent stable version according to your platform, from the links mentioned below:
Python for Linux (Install the python2.x and python2.x-dev packages)
NOTE: You can go through “Python download guide“ if there’s any confusion.
- Once the installation is done, do check whether it’s running on your PC or not by entering python in a command line window. If you see a response from a Python interpreter it will include a version number in its initial display.
- Next, we need to enable access to the Google Assistant API in the Google Cloud Platform Console, before we install the necessary files to get Google Assistant working.
- This can be done by following these steps:
- Go to the Projects page in the Google Cloud Platform Console.
- Click on “Create Project” up top.
- Name the Project “My Google Assistant” and click “Create.”
- Wait a few seconds for the Console to create your new Project. You should see a spinning progress icon in the top right. After it is done creating your Project, you will be brought to your Project’s configuration page.
- Click this link to go straight to the Google Assistant API page. Up top, click “Enable.”
- Google will warn you that you need to create credentials to use this API. Click “Create credentials” in the top right. This will take you to a setup wizard page where Google helps you figure out what kind of credentials you need to use this API.
- Under “where will you be calling the API from”, select “Other UI (e.g. Windows, CLI tool)“. For “what data will you be accessing” select the “User data” circle. Now tap “what credentials do I need?”
- Google should recommend that you create an OAuth 2.0 client ID. Name the Client ID anything you want, for example, your name + Desktop. Once done picking a name, click “create client ID.”
- Under “product name shown to users” enter “My Google Assistant.” Click continue.
- Click “done.” There’s no need to click download here as we only need the client secret, which we will download next.
- Now under the list of OAuth 2.0 client IDs, you should see the client ID you just made. All the way to the right, click on the download icon to download the client_secret_XXX.json file, where ‘XXX’ is your client ID. Save this file anywhere on your computer, ideally in a new folder called “googleassistant.”
- Go to the Activity controls page for your Google account and make sure that “Web & App Activity”, “Location History”, “Device Information”, and “Voice & Audio Activity” are enabled. This is so Google Assistant can actually read you personalized information.
Now we need to set up the client that will access the Google Assistant API.
- Open up a terminal/command prompt window and go through the following steps. First, enter this command:
py -m pip install google-assistant-sdk[samples]
- You should see a whole bunch of dependencies being downloaded and installed when you enter this command. Wait for it to finish.
- Once it’s done, enter the following command:
py -m googlesamples.assistant.auth_helpers –client-secrets path\to\your\client_secret_XXX.apps.googleuse
- In the command prompt, you will see a response telling you to visit a URL in order to authorize the application.
- Copy and paste this URL into your browser. Make sure you Select the same Google account that you used to configure the Google Assistant API.
- Now On the next page, you will see a text box showing your client’s Access Token. Copy this Access token and paste it into the command prompt where it asks you for the authorization code. You will see a response that your credentials have been saved.
- After this initial setup, the first thing you’ll want to test is whether or not Google Assistant is able to record audio from your microphone. Enter the following command into a command prompt, which will record 5 seconds of audio and play it back to you:
python -m googlesamples.assistant.audio_helpers
- If you hear your audio played back to you, then enter this command to begin talking to Google Assistant:
python -m googlesamples.assistant
- Wait for the command prompt to say “press Enter to send a new request”, then press Enter to begin talking to Google Assistant.
- After you’re done speaking, the command prompt will display a transcript of what you just stated and then play back the response. Ignore any warning prompt that appears.
So that’s it for this post. Perhaps we may see some desktop apps or browser extensions taking advantage of this new functionality in the near future.