diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 601319c..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/README.md b/README.md index 5a1f05b..a3438e3 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,40 @@ Noise Delay | This increase the delay after the wake-up word has been activated Sensitivity | This setting changes the sensitivity of the wake-up word detection. This setting is found on the front page for each command. The lower the number the less sensitive. | `20` +### Automatic Install (tested on 2020-02-13-raspbian-buster-lite) +If you wish to install it on your SO, you can use our automatic install script + +1. Download the latest version of **[Raspbian Stretch](https://www.raspberrypi.org/downloads/raspbian/)** and flash your micro SD card with **[Etcher](https://etcher.io/)** + + +2. Copy the **ssh** and **wpa_supplicant.conf** files from the **[setup folder](setup/)** to the SD card (boot) + + +3. Edit the **wpa_supplicant.conf** in a text editor to match your wifi settings. Insert the card to the raspberry pi + + +4. In terminal ssh into the pi: ```sudo ssh pi@raspberrypi.local```
*Default password is 'raspberry'. To change password use the 'passwd' command* + +5. Clone project_alias repo and execute install script: +``` +sudo apt update -y && sudo apt upgrade -y && sudo apt install git -y +cd $HOME && git clone https://github.com/bjoernkarmann/project_alias.git +cd $HOME/project_alias/setup/ && ./install_script.sh +``` ### Manual Install If you wish to build this project manually, you can follow the guide below. We do recommend using the pre installed image linked in the Easy Setup. +1. Download the latest version of **[Raspbian Stretch](https://www.raspberrypi.org/downloads/raspbian/)** and flash your micro SD card with **[Etcher](https://etcher.io/)** + + +2. Copy the **ssh** and **wpa_supplicant.conf** files from the **[setup folder](setup/)** to the SD card (boot) + + +3. Edit the **wpa_supplicant.conf** in a text editor to match your wifi settings. Insert the card to the raspberry pi + + +4. In terminal ssh into the pi: ```sudo ssh pi@raspberrypi.local```
*Default password is 'raspberry'. To change password use the 'passwd' command* #### RaspberryPi Setup How to prepare and setup a Raspberry Pi for this project: diff --git a/alias.service b/alias.service index b848206..cbc09d6 100755 --- a/alias.service +++ b/alias.service @@ -5,9 +5,10 @@ Requires=network.target [Service] Type=idle +Environment="DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus" "XDG_SESSION_TYPE=tty" "XDG_SESSION_CLASS=user" "XDG_SESSION_ID=c1" "XDG_RUNTIME_DIR=/run/user/1000" ExecStartPre=/usr/bin/python3 -u sleep.py ExecStart=/usr/bin/python3 -u app.py > /home/pi/sample.log 2>&1 -WorkingDirectory=/home/pi/project_alias-2.0 +WorkingDirectory=/home/pi/project_alias StandardOutput=inherit StandardError=inherit Restart=always diff --git a/app.py b/app.py index 1669618..c09a78a 100755 --- a/app.py +++ b/app.py @@ -130,7 +130,16 @@ def run(self): globals.GLOW = True noise.stop() print('say:', data['whisper']) - sound.speak(data['whisper']) + if data['whisper'].lower() == "ok google": + okgoogle.play() + time.sleep(0.6) + okgoogle.stop() + elif data['whisper'].lower() == "alexa": + alexa.play() + time.sleep(0.5) + alexa.stop() + else: + sound.speak(data['whisper']) time.sleep(int(globals.SETTING['setting']['delay'])) noise.play() @@ -214,6 +223,8 @@ def main(): #Initialize the sound objects globals.initialize() noise = sound.audioPlayer(globals.NOISE_PATH) + okgoogle = sound.audioPlayer(globals.OKGOOGLE_PATH) + alexa = sound.audioPlayer(globals.ALEXA_PATH) thread_socket = Thread(target=socket_thread) thread_socket.daemon = True diff --git a/data/alexa.wav b/data/alexa.wav new file mode 100755 index 0000000..1f05769 Binary files /dev/null and b/data/alexa.wav differ diff --git a/data/ok_google.wav b/data/ok_google.wav new file mode 100755 index 0000000..234fd52 Binary files /dev/null and b/data/ok_google.wav differ diff --git a/imgs/.DS_Store b/imgs/.DS_Store deleted file mode 100644 index a7e2f3c..0000000 Binary files a/imgs/.DS_Store and /dev/null differ diff --git a/modules/globals.py b/modules/globals.py index 3a4f8d6..13f5f57 100755 --- a/modules/globals.py +++ b/modules/globals.py @@ -31,10 +31,12 @@ def initialize(): - global ROOT_PATH, KEYWORD_PATH, NOISE_PATH, SETTINGS_PATH + global ROOT_PATH, KEYWORD_PATH, NOISE_PATH, OKGOOGLE_PATH, ALEXA_PATH, SETTINGS_PATH # absolute file paths ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) KEYWORD_PATH = os.path.join(ROOT_PATH, '../data/keyphrase.list') NOISE_PATH = os.path.join(ROOT_PATH, '../data/noise.wav') + OKGOOGLE_PATH = os.path.join(ROOT_PATH, '../data/ok_google.wav') + ALEXA_PATH = os.path.join(ROOT_PATH, '../data/alexa.wav') SETTINGS_PATH = os.path.join(ROOT_PATH, '../data/settings.txt') diff --git a/setup/.DS_Store b/setup/.DS_Store deleted file mode 100644 index 93877e5..0000000 Binary files a/setup/.DS_Store and /dev/null differ diff --git a/setup/install_script.sh b/setup/install_script.sh new file mode 100755 index 0000000..b7afe41 --- /dev/null +++ b/setup/install_script.sh @@ -0,0 +1,95 @@ +#!/bin/bash + + +# Check if cloned repository is in correct PATH +SCRIPT=`realpath $0` +SCRIPTPATH=`dirname $SCRIPT` +if [[ "$SCRIPTPATH" != "$HOME/project_alias/setup" ]]; then + GIT_PATH=$(echo $SCRIPTPATH | sed "s/\/setup//g") + echo "" + echo "########################" + echo "Incorrect Git clone PATH" + echo "Actual: $GIT_PATH" + echo "Should be: $HOME/project_alias" + echo "########################" + echo "" + exit 1 +fi + + +echo "" +echo "# Upgrade before start" +echo "" +sudo apt update -y -q +sudo apt upgrade -y -q + +echo "" +echo "# Enable SPI module" +echo "" +sudo sed -i "s/#dtparam=spi/dtparam=spi/g" /boot/config.txt + +echo "" +echo "# Enable pi user console autologin (needed to communicate to dbus)" +echo "" +sudo systemctl set-default multi-user.target +sudo ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service +sudo bash -c 'cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin pi --noclear %I \$TERM +EOF' + +echo "" +echo "# Install python basic tools" +echo "" +sudo apt install -q -y python3-dev python3-pip git libatlas-base-dev + +echo "" +echo "# Install ReSpeaker driver" +echo "" +cd $HOME +git clone https://github.com/respeaker/seeed-voicecard.git +cd seeed-voicecard +sudo ./install.sh + +echo "" +echo "# Disable default soundcard" +echo "" +echo "blacklist snd_bcm2835" | sudo tee -a /etc/modprobe.d/alsa-blacklist.conf + +echo "" +echo "# Installing python dependencies" +echo "" +sudo pip3 install spidev +sudo apt install -y -q python python-dev python-pip build-essential swig git libpulse-dev libasound2-dev pulseaudio pulseaudio-utils libpulse-dev libpulse-java libpulse0 +sudo pip3 install --upgrade pocketsphinx + +echo "" +echo "# Install espeak" +echo "" +sudo apt -y -q install espeak + +echo "" +echo "# Install flask" +echo "" +sudo pip3 install flask flask_socketio + +echo "" +echo "# Install pygame" +echo "" +sudo apt install -y -q python3-pygame + +echo "" +echo "# Change alias service and install on systemd" +echo "" +cd $HOME/project_alias +sudo cp alias.service /lib/systemd/system/ +sudo systemctl enable alias.service +echo "" +echo "####################" +echo "# Executing REBOOT #" +echo "####################" +echo "" +sudo reboot + +