Created
March 16, 2019 17:39
-
-
Save ryo1kato/13d6ca6d34ec4f5de69b8bed40ec921c to your computer and use it in GitHub Desktop.
right and light
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ue | |
voices=($(say -v '?' | egrep 'en_US|en_UK' | egrep -v 'Pipe Organ|Bubbles|Bells|Bahh|Hysterical|Boing|Bad|Albert'| awk '{print $1}')) | |
nr_voices=${#voices[@]} | |
correct=0 | |
wrong=0 | |
RANDMAX=32767 | |
hist=() | |
for i in {1..10} | |
do | |
#v=$((RANDOM % nr_voices)) | |
v=$((RANDOM / (RANDMAX / nr_voices) )) | |
eval rand_voice="\${voices[$v]}" | |
#if (( RANDOM % 2 == 0 )) | |
if (( RANDOM > RANDMAX/2 )) | |
then | |
ans=right | |
say -v "$rand_voice" 'right' | |
else | |
ans=light | |
say -v "$rand_voice" 'light' | |
fi | |
read -p "Answer? [r/l] " guess | |
if [ "${guess:0:1}" = "${ans:0:1}" ] | |
then | |
echo " > Correct: it was $ans (voice=${rand_voice})" | |
let ++correct | |
else | |
echo " > *** WRONG ***: it was $ans (voice=${rand_voice})" | |
let ++wrong | |
fi | |
done | |
echo "correct: $correct" | |
echo "wrong: $wrong" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment