Skip to content

Instantly share code, notes, and snippets.

@JarbasAl
Created December 8, 2018 16:25
Show Gist options
  • Select an option

  • Save JarbasAl/62568e696114197a7e3d0c4e40b45a09 to your computer and use it in GitHub Desktop.

Select an option

Save JarbasAl/62568e696114197a7e3d0c4e40b45a09 to your computer and use it in GitHub Desktop.
Aiy_asound.conf
#!/bin/bash
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
set -e
sed -i \
-e "s/^dtparam=audio=on/#\0/" \
-e "s/^#\(dtparam=i2s=on\)/\1/" \
/boot/config.txt
grep -q "dtoverlay=i2s-mmap" /boot/config.txt || \
echo "dtoverlay=i2s-mmap" >> /boot/config.txt
grep -q "dtoverlay=googlevoicehat-soundcard" /boot/config.txt || \
echo "dtoverlay=googlevoicehat-soundcard" >> /boot/config.txt
grep -q "dtparam=i2s=on" /boot/config.txt || \
echo "dtparam=i2s=on" >> /boot/config.txt
options snd_rpi_googlevoicehat_soundcard index=0
pcm.softvol {
type softvol
slave.pcm dmix
control {
name Master
card 0
}
}
pcm.micboost {
type route
slave.pcm dsnoop
ttable {
0.0 30.0
1.1 30.0
}
}
pcm.!default {
type asym
playback.pcm "plug:softvol"
capture.pcm "plug:micboost"
}
ctl.!default {
type hw
card 0
}
#!/bin/bash
#
# Replace the Raspberry Pi's default ALSA config with one for the voiceHAT.
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
cd $(dirname $0)
TOP=$( pwd -L )
asoundrc=/home/pi/.asoundrc
global_asoundrc=/etc/asound.conf
for rcfile in "$asoundrc" "$global_asoundrc"; do
if [[ -f "$rcfile" ]] ; then
echo "Renaming $rcfile to $rcfile.bak..."
sudo mv "$rcfile" "$rcfile.bak"
fi
done
sudo cp "$TOP/AIY_asound.conf" "$global_asoundrc"
echo "Installed voiceHAT ALSA config at $global_asoundrc"
#!/usr/bin/env bash
cd $(dirname $0)
TOP=$( pwd -L )
echo "Google AIY Voice HAT and microphone board (Voice Kit v1)"
# Get AIY drivers
echo "deb https://dl.google.com/aiyprojects/deb stable main" | sudo tee -a /etc/apt/sources.list.d/aiyprojects.list
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-get update -y
sudo apt-get upgrade -y
# hack to get aiy-io-mcu-firmware to be installed
sudo mkdir /usr/lib/systemd/system
sudo apt-get install libatlas-base-dev apt-transport-https raspberrypi-kernel-headers dkms -y
sudo apt-get -y install aiy-dkms aiy-io-mcu-firmware -y
sudo apt-get install aiy-voicebonnet-soundcard-dkms aiy-voicebonnet-routes -y
sudo apt-get install leds-ktd202x-dkms -y
#sudo apt-get -y install aiy-python-wheels
# make changes to mycroft.conf
sudo sed -i \
-e "s/aplay -Dhw:0,0 %1/aplay %1/" \
-e "s/mpg123 -a hw:0,0 %1/mpg123 %1/" \
/etc/chatterbox/chatterbox.conf
sudo chmod +x ./configure-driver.sh
sudo chmod +x ./install-alsa-config.sh
# make soundcard recognizable
sudo "$TOP/configure-driver.sh"
# Install asound.conf / this one maybe is optional
sudo "$TOP/install-alsa-config.sh"
echo "Reboot is needed !"
sudo reboot now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment