nerdaxic / glados-voice-assistant

DIY Voice Assistant based on the GLaDOS character from Portal video game series. Works with home assistant!
https://www.henrirantanen.fi/2022/02/10/glados-voice-assistant-with-custom-text-to-speech/?utm_source=github.com&utm_medium=social&utm_campaign=post&utm_content=DIY+GLaDOS+Voice+Assistant+with+Python+and+Raspberry+Pi
Other
279 stars 23 forks source link
glados glados-tts home-assistant home-automation tts voice-assistant

GLaDOS Voice Assistant

DIY Voice Assistant based on the GLaDOS character from Portal video game series. ## Featured on: 🛠 [Hackday](https://hackaday.com/2021/09/13/glados-voice-assistant-passive-aggressively-automates-home/) - Tech blog 🛠 [Tom's Hardware](https://www.tomshardware.com/news/raspberry-pi-glados-voice-assistant-head) - Technology news 🎮 [PCGamer](https://www.pcgamer.com/this-guy-decided-to-mock-our-future-ai-overlords-with-a-glados-smart-assistant/) - Online magazine 🇫🇮 [Ilta-Sanomat](https://www.is.fi/digitoday/art-2000008642371.html) - The second largest newspaper in Finland 🇫🇮 [Muropaketti](https://muropaketti.com/tietotekniikka/tietotekniikkauutiset/onpas-hieno-suomalainen-youtube-kayttaja-teki-portal-pelin-glados-tekoalyrobotista-huiman-hienon-aaniavustajan/) - Finnish computing website 📺 [YouTube](https://www.youtube.com/playlist?list=PLs-qfwv3feinbxvTzFtmrHJrGSMrR09-t) - GLaDOS Voice Assistant playlist

Read project article first!

📄 GLaDOS Voice Assistant - henrirantanen.fi

Description

❗ New versions of the voice assistant will not work on Raspberry Pi due to missing CPU instruction sets needed by some AI scripts. If you are looking to play along with the old version on your Raspberry Pi, check the raspberry branch.

Main features

  1. Local Trigger word detection using PocketSphinx
  2. Local GLaDOS Text-to-Speech engine using glados-tts model by R2D2FISH
  3. Speech-to-text processing using Google's API (for now)
  4. Local TTS cache of generated common audio samples locally for instant answers in the future
  5. Animatronic eye control using servos
  6. Round LCD for an eye to display display textures

Tight integration with Home Assistant's local API:

What it can do:

Note: The code is provided as reference only.

Voice Assistant pipeline overview

General AI Voice Assistant Pipeline

Requirements for Ubuntu

Install tools

sudo apt-get update
sudo apt-get upgrade
sudo apt install python3-pip

Install PyAudio

PyAudio is needed to play audio files.

sudo apt-get install portaudio19-dev 

Install PocketSphinx

Used for trigger word detection for now.

sudo apt-get install -y build-essential swig libpulse-dev libasound2-dev

Install SpeechRecognition

Used to turn audio into text for now.

sudo apt-get install flac

Install other libraries

Install python modules from requirements.txt file

cd ~/glados-voice-assistant
sudo pip3 install -r requirements.txt

Install pytorch

See here: https://pytorch.org/get-started/locally/#start-locally

Install GLaDOS Voice Assistant

1. Go to home folder

cd ~

2. Download the source from GitHub

This will download GLaDOS Voice Assistant and the TTS submodule.

git clone --recurse-submodules https://github.com/nerdaxic/glados-voice-assistant/

After this you can play around with the TTS, this works as stand-alone.

cd ~/glados-voice-assistant/glados_tts/
python3 glados.py

3. Edit the settings file

Find the sound card ID:

python3 -m sounddevice

Generate and edit the settings.env file:

cp ~/glados-voice-assistant/settings.env.sample ~/glados-voice-assistant/settings.env && nano ~/glados-voice-assistant/settings.env

4. To run:

Launch the voice assistant:

python3 ~/glados-voice-assistant/glados.py

You can add glados.py to your crontab file or run it manually.

crontab -e
@reboot python3 /home/username/glados-voice-assistant/glados.py

Integrate to Home Assistant

To make Home Assistant integration work, you need to enable the API in the home assistant configuration file and generate a long-lived access token. Add access token and IP-address of the home assistant server into the settings.env file.

configuration.yaml

# This will enable rest api
api:

# This will add GLaDOS as a notification provider. Replace with correct IP of GLaDOS.
notify:
  - name: glados
    platform: rest
    resource: http://192.168.1.XXX:5000/notify

Hardware

List of reference hardware what nerdaxic is developing on, models might not need to be exact. Not a full bill of materials. Item Description
Main board Basic i7 laptop with 16 gigs of RAM
Operating system ubuntu-20.04.3-desktop-amd64
Microcontroller Teensy 4, to control the eye LCD and NeoPixels
Eye lights Adafruit NeoPixel Diffused 5mm Through-Hole for the "REC" light
Eye lights Adafruit 16 x 5050 NeoPixel Ring
Eye LCD 1.28 Inch TFT LCD Display Module Round, GC9A01 Driver SPI Interface 240 x 240

Audio

Audio amp is powered from Raspberry GPIO 5V line and ReSpeaker board from USB to avoid ground loops and noise issues. Item Description
Audio amplifier Adafruit Stereo 3.7W Class D Audio Amplifier
Speakers Visaton FRS 7
Microphone & Audio interface ReSpeaker Mic Array V2.0

Mechanics

Mechanics are powered from their own power supply to allow more power for the servos and prevent brown-outs. Item Description
Power supply MeanWell LRS-50-5 5V
Servo controller Pololu Micro Maestro
Servo: Eye movement 35 kg DS3235 (Control Angle 180)
Servo: Eyelids 25 kg DS3225 (Control Angle 180)
Screws Various M3 and M4 screws
Jumper wires 0.32 mm²/22 AWG assortment