Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matrix voice support #84

Merged
merged 3 commits into from
Dec 17, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 148 additions & 50 deletions home/pi/auto_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ function setup_wizard() {
echo " 1) PlayStation Eye (USB)"
echo " 2) Blue Snoball ICE (USB)"
echo " 3) Google AIY Voice HAT and microphone board (Voice Kit v1)"
echo " 4) Other (unsupported -- good luck!)"
echo " 4) Matrix Voice HAT."
echo " 5) Other (unsupported -- good luck!)"
echo -n "Choice [1-4]: "
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
echo
while true; do
Expand All @@ -301,6 +302,16 @@ function setup_wizard() {
break
;;
4)
echo "$key - Matrix Voice Hat"
echo "The setup script for Matrix Voice Hat will run at the end of"
echo "The setup wizard. Press any key to continue..."
read -N1 -s anykey
touch setup_matrix # setting flag to run setup_matrix_voice.sh
skip_mic_test=true
skip_last_prompt=true
break
;;
5)
echo "$key - Other"
echo "Other microphone _might_ work, but there are no guarantees."
echo "We'll run the tests, but you are on your own. If you have"
Expand All @@ -311,47 +322,52 @@ function setup_wizard() {
esac
done

echo
echo "Testing microphone..."
echo "In a few seconds you will see some initialization messages, then a prompt"
echo "to speak. Say something like 'testing 1 2 3 4 5 6 7 8 9 10'. After"
echo "10 seconds, the sound heard through the microphone will be played back."
echo
echo "Press any key to begin the test..."
sleep 1
read -N1 -s key
if [ ! $skip_mic_test ]; then
echo
echo "Testing microphone..."
echo "In a few seconds you will see some initialization messages, then a prompt"
echo "to speak. Say something like 'testing 1 2 3 4 5 6 7 8 9 10'. After"
echo "10 seconds, the sound heard through the microphone will be played back."
echo
echo "Press any key to begin the test..."
sleep 1
read -N1 -s key

# Launch mycroft-core audio test
./mycroft-core/start-mycroft.sh audiotest
# Launch mycroft-core audio test
./mycroft-core/start-mycroft.sh audiotest

retry_mic=0
echo
echo "Did you hear the yourself in the audio?"
echo " 1) Yes!"
echo " 2) No, let's repeat the test."
echo " 3) No :( Let's move on and I'll mess with the microphone later."
echo -n "Choice [1-3]: "
while true; do
read -N1 -s key
case $key in
[1])
echo "$key - Yes, good to go"
break
;;
[2])
echo "$key - No, trying again"
echo
retry_mic=1
break
;;
[3])
echo "$key - No, I give up and will use command line only (for now)!"
retry_mic=0
echo
echo "Did you hear the yourself in the audio?"
echo " 1) Yes!"
echo " 2) No, let's repeat the test."
echo " 3) No :( Let's move on and I'll mess with the microphone later."
echo -n "Choice [1-3]: "
while true; do
read -N1 -s key
case $key in
[1])
echo "$key - Yes, good to go"
break
;;
[2])
echo "$key - No, trying again"
echo
retry_mic=1
break
;;
[3])
echo "$key - No, I give up and will use command line only (for now)!"
break
;;
esac
done

if [ $retry_mic -eq 0 ] ; then
break
;;
esac
done
fi

if [ $retry_mic -eq 0 ] ; then
else
break
fi
done
Expand Down Expand Up @@ -465,18 +481,20 @@ function setup_wizard() {
echo "pi ALL=(ALL) ALL" | sudo tee /etc/sudoers.d/010_pi-nopasswd
fi

echo
echo "========================================================================="
echo
echo "That's all, setup is complete! Now we'll pull down the latest software"
echo "updates and start Mycroft. You'll be prompted to pair this device with"
echo "an account at https://home.mycroft.ai, then you'll be set to enjoy your"
echo "Picroft!"
echo
echo "To rerun this setup, type 'mycroft-setup-wizard' and reboot."
echo
echo "Press any key to launch Mycroft..."
read -N1 -s anykey
if [ ! $skip_last_prompt ]; then
echo
echo "========================================================================="
echo
echo "That's all, setup is complete! Now we'll pull down the latest software"
echo "updates and start Mycroft. You'll be prompted to pair this device with"
echo "an account at https://home.mycroft.ai, then you'll be set to enjoy your"
echo "Picroft!"
echo
echo "To rerun this setup, type 'mycroft-setup-wizard' and reboot."
echo
echo "Press any key to launch Mycroft..."
read -N1 -s anykey
fi
}

function speak() {
Expand Down Expand Up @@ -548,6 +566,85 @@ then
rm ~/first_run
fi

# Matrix Voice Hat Setup
if [ -f ~/setup_matrix ]
then
if [ ! -f matrix_setup_state.txt ]
then
echo ""
echo "========================================================================="
echo "Setting up Matrix Voice Hat. This will install the matrixio-kernel-modules and pulseaudio"
echo "This will require 3 reboots"
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
echo "Press any key to continue..."
read -N1 -s anykey
else
echo "Press any key to continue setting up Matrix Voice HAT"
read -N1 -s anykey
fi

if [ ! -f matrix_setup_state.txt ]
then
echo "Add Matrix repo and key and Update and install packages"
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
# add repo
curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.matrix.one/raspbian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/matrixlabs.list
sudo apt-get update -y
sudo apt-get upgrade -y

echo "stage-1" > matrix_setup_state.txt
echo "Needs to reboot in case of kernel updates"
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
read -p "Press enter to continue reboot"
sudo reboot
else
matrix_setup_state=$( cat matrix_setup_state.txt)
fi

if [ $matrix_setup_state == "stage-1" ]
then
echo "installing matcixio-kernel-modules"
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
sudo apt install matrixio-kernel-modules -y

echo "installing pulseaudio"
sudo apt-get install pulseaudio -y

echo "Need to reboot after installing matcixio-kernel-modules and pulseaudio"
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
read -p "Press enter to continue reboot"
echo "stage-2" > matrix_setup_state.txt
sudo reboot
fi

if [ $matrix_setup_state == "stage-2" ]
then
echo "setting Matrix as standard microphone..."
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
echo "========================================================================="
pactl list sources short
sleep 5
pulseaudio -k
pactl set-default-source 2
pulseaudio --start
amixer
amixer set Master 99%
amixer
sleep 2
amixer

mycroft-mic-test

read -p "You should have heard the recording playback. Press enter to continue"

echo "========================================================================="
echo "updating the python virtual environment"
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
bash mycroft-core/dev_setup.sh

echo "stage-3" > matrix_setup_state.txt
read -p "Press enter to continue reboot! this should be the last one"
LearnedVector marked this conversation as resolved.
Show resolved Hide resolved
sudo reboot
fi

rm ~/matrix_setup_state.txt
rm ~/setup_matrix
fi


if [ "$SSH_CLIENT" == "" ] && [ "$(/usr/bin/tty)" = "/dev/tty1" ];
then
Expand Down Expand Up @@ -646,6 +743,7 @@ echo "Ctrl+C to stop showing the log and return to the Linux command line."
echo "Mycroft will continue running in the background for voice interaction."
echo

source ~/mycroft-core/start-mycroft.sh all &
sleep 5 # for some reason this delay is needed for the mic to be detected
"$HOME/mycroft-core/start-mycroft.sh" cli