Google Assistant is available on nearly every Android phone recently made, but there’s currently no desktop version available. However, today I’ll show you a (somewhat tedious) method of getting Google Assistant running on your Windows machine.
As of this writing, there’s no fancy GUI for what we’re about to do, and the installation is going to rely primarily on command lines. But once you’ve got it up and running, you can speak into your computer’s microphone as you would to your Android device to control Google Assistant.
First you’ll need to install Python on your computer, but follow me carefully. Download and launch the Python installer .exe, and have it do a custom install. On the second options screen, tick “Add Python to environment variables”.
Once Python is installed, open a command terminal and type “python” (without quotations). If all is well, the command prompt should display your current Python version.
Now we need to configure the Google Assistant API.
- Navigate to the Projects page in the Google Cloud Platform Console.
- Click on “Create Project” up top.
- Give the project a name like “Google Assistant” and click “Create.”
- The Console will create your new project – you should see a spinning progress icon in the top right. When it’s done, you’ll be brought to the project configuration page.
- Go to the Google Assistant API page and click “Enable” at the top.”
- To use the API, you’ll need to create credentials. So click the “Create credentials” button in the top right. A setup wizard will walk you through this process.
- Underneath “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 click “what credentials do I need?”
- Google will recommend that you create an OAuth 2.0 client ID. Give the client ID a unique name and click “create client ID.”
- Under “product name shown to users” enter “My Google Assistant” or something like that.
- Click “done”, but do not click the download here, we only need the client secret.
- Under the list of OAuth 2.0 client IDs, you’ll see the client ID you just made. On the far 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 configure a client that will access the Google Assistant API.
Open a command terminal and type the following command:
py -m pip install google-assistant-sdk[samples]
This will begin installing the required dependencies for Python. When it’s done, enter this command next (change the path directory in the command): py –m googlesamples.assistant.auth_helpers —client–secrets change\your\path\client_secret_XXX.apps.googleusercontent.com.json
In the command prompt, you will be shown a URL to visit to authorize the application. Go ahead and copypaste the URL into your browser, and use the same Google account you used to configure the Google Assistant API. You’ll be shown an access token for your client – copypaste the access token into the command prompt where asked.
Now we’ll test if the Google Assistant can properly access your microphone. Type into the command prompt:
python -m googlesamples.assistant.audio_helpers
If it successfully plays some audio for you, you can begin communicating with the Google Assistant. Type into the command prompt:
python -m googlesamples.assistant
Wait for it to say “press Enter to send new request”, then press Enter on your keyboard to begin talking into your mic. When you’re done talking, the command prompt will display a transcription of what you said, and also play back Google Assistant’s response.
Now, the above command prompt is a fairly ugly method of interacting with the Google Assistant API, but luckily there is an extension for Chrome browser called “AutoVoice” that simply requires you have the Google Assistant set up on your computer (which we just did!). However, we’ll need to do a little bit more command prompt magic to set it up properly.
Open the command prompt and copypaste the following command:
py -c “from distutils.sysconfig import get_python_lib; from urllib.request import urlretrieve; urlretrieve(‘https://joaoapps.com/AutoApps/Help/Info/com.joaomgcd.autovoice/googleassistant/__main__.py’, get_python_lib() + ‘/googlesamples/assistant/__main__.py’)”
Now navigate to the AutoVoice extension page with Google Chrome browser and install it. In the extension options, configure the wake up command to something like “Hey Google” or “Okay Google” or whatever you want really.
Enable the “Always Listening” option and set the “Wake up Expression” to something other than what you set as the wake up command. Remember – one expression is to wake up the extension, the other expression is to wake up Google Assistant.
Now type into your command prompt: py -m googlesamples.assistant
Now you can simply say “Hey Google!” or whatever you set as your expression to wake up Google Assistant, and immediately begin giving it commands (“Hey Google, what’s the weather today?”)