Google Assistant on RPI

Google Assistant on RPI (All Models 2-4)

By Darsh K


This may seem like a lot, but I have a strong feeling that you can do it.


  1. Connect your RPI to a display through the HDMI port and startup the Pi

  2. Plug in your 3.5 mm Jack for the external Speaker

  3. Plug in your USB Mic

  4. On the RPI go to https://console.cloud.google.com

  5. Click the “Select a project” drop down menu and click “NEW PROJECT”

  6. Change project name to “GARP” and leave the Organization alone and click “Create”

  7. Click the 3 bars for the navigation menu, hover over “APIs & Services”, and click “Credentials”

  8. Use the “Select a project” drop down and click “GARP”

  9. Go to the “OAuth consent screen” and change the “Application Name” to “GARP”

  10. Scroll down and click “Save”

  11. Click “Create Credentials” and select “OAuth Client ID”

  12. In the “Application Type” select “Other”, name it “GARP”, and click “Create”

  13. Click "OK" in the OAuth client box.

  14. Go to the 3 bars for the navigation menu and hover over “APIs & Services” and click “Library”

  15. Search for “Google Assistant API” and click it. Then click “ENABLE”

  16. Now go back to the “Credentials” section under “APIs & Services”

  17. Click the download button in the row of “GARP”. (The download button should be near the pencil and trash can icons)

  18. Go to https://myaccount.google.com/activitycontrols and turn everything on so that you don’t get any errors when using the Assistant.

  19. Open Terminal on the RPI and type:

cd

20. Hit "Enter" and then type:

sudo nano .asoundrc

21. Hit "Enter" and input the following:

pcm.!default {

type asym

capture.pcm "mic"

playback.pcm "speaker"

}

pcm.mic {

type plug

slave {

pcm "hw:1,0"

}

}

pcm.speaker {

type plug

slave {

pcm "hw:0,0"

}

}

22. Hit “Ctrl x” then “y” then “Enter”

23. In terminal, type:

cd /etc

24. Hit "Enter" and type:

sudo nano asound.conf

25. Repeat steps 21 and 22

26. In a new Terminal window type:

sudo git clone https://github.com/DarshKTK/gassistrpi

27. Hit "Enter" and type:

cd gassistrpi

28. Hit "Enter" and type:

sudo nano installer.sh

29. Hit "Enter" and find "THE NAME OF THE DOWNLOADED CLIENT JSON FILE" in the final command. (It will look like this: google-oauthlib-tool --client-secrets /home/pi/Downloads/THE NAME OF THE DOWNLOADED CLIENT JSON FILE --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless). Now replace "THE NAME OF THE DOWNLOADED CLIENT JSON FILE" with the exact name of the downloaded client json file that is in your downloads folder

30. Hit "Ctrl x", "y", and "Enter"

31. Now type:

sudo chmod +x installer.sh

32. Hit "Enter" and now type:

sudo ./installer.sh

33. Hit "Enter" and wait until you get to the point "Enter the authorization code", hover over the URL in Terminal and right click and click “Copy URL”

34. Open the web browser on RPI and go to that URL.

35. Sign In to the email you used for steps 4-18 and And click “Allow” and click “Allow” again.

36. Copy the code that Google gives you and paste it into Terminal.

37. Hit “Enter” and after it says “credentials saved” go to the next step

38. Type:

sudo chmod +x autostart.sh & sudo chmod +x manualstart.sh

39. Hit “Enter” and type:

alsamixer

40. Use the Up and Down keys to adjust the volume (to your satisfaction) and press “f6” and use the Up and Down keys to select the “USB PnP Sound Device” and hit “Enter”. Hit “f4” and keep the Up key pressed until you see the red section of the bar. Hit the Down key until the red section just disappears and finally hit “esc”

41. In the terminal type:

sudo raspi-config

42. Hit "Enter" and select "Advanced Options" and choose "Audio". Select the "Force 3.5 mm Jack" option. Then select "Finish"

43. Make sure that your speaker is on and then type:

sudo ./manualstart.sh

44. Hit “Enter” and then wait 5 seconds and say “OK Google” or “Hey Google”. Follow that with “Are you there” and if you get a valid response (that is not an error) then it has worked.

45. Press “Ctrl C” and exit the Terminal window and open a new one.

46. Type in the terminal:

cd /etc

47. Hit “Enter” and type:

sudo nano rc.local

48. Hit “Enter” and replace all with the following:

#!/bin/sh -e

#

# rc.local

#

# Run Google Assistant

sudo ./home/pi/gassistrpi/autostart.sh &

exit 0

49. Press “Ctrl X” then “y” then “Enter”

50. Type:

sudo chmod +x rc.local

51. Now Google Assistant will run automatically when you turn on your RPI.

52. Type:

cd

53. Hit "Enter" and type:

sudo raspi-config

54. Hit "Enter" and go to "Boot Options". Select "Wait for Network at Boot" and select "Yes". Hit "Enter" and now go back to "Boot Options" and select "Desktop / CLI" and then select "Console Autologin". Select "Finish". After this, if it asks you to reboot, select "Yes".

55. Now when your RPI boots up it should automatically launch the Google Assistant. Now you should not see your desktop, you should see a terminal console instead. You now have a fully functional DIY Google Assistant. If Google Assistant does not start within 5 minutes from startup, just turn the RPI off and on again.

If you encounter any errors or you have any questions, feel free to send me an email at [email protected].