Created
December 1, 2016 00:00
-
-
Save mrardon/de8ebe76a1f8b9e06f04832d2b1bebed to your computer and use it in GitHub Desktop.
Uses AWS CLI tool to create mp3s in current directory for each phrase for each english voice (requires bash version 4+). Tested on MacOS Sierra
This file contains 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
#!/usr/local/bin/bash | |
declare -A array | |
array[1]="Front door closed" | |
array[2]="Front door opened" | |
array[3]="Garage door closed" | |
array[4]="Garage door closing" | |
array[5]="Garage door open" | |
array[6]="Garage door opening" | |
array[7]="Garage entry door closed" | |
array[8]="Garage entry door opened" | |
array[9]="Master bedroom door closed" | |
array[10]="Master bedroom door opened" | |
array[11]="Office door closed" | |
array[12]="Office door opened" | |
array[13]="Sunroom door closed" | |
array[14]="Sunroom door opened" | |
declare -A voices | |
voices[Joanna]="Female/US_English/Joanna" | |
voices[Geraint]="Male/Welsh_English/Geraint" | |
voices[Salli]="Female/US_English/Salli" | |
voices[Kimberly]="Female/US_English/Kimberly" | |
voices[Kendra]="Female/US_English/Kendra" | |
voices[Justin]="Male/US_English/Justin" | |
voices[Joey]="Male/US_English/Joey" | |
voices[Ivy]="Female/US_English/Ivy" | |
voices[Raveena]="Female/Indian_English/Raveena" | |
voices[Emma]="Female/British_English/Emma" | |
voices[Brian]="Male/British_English/Brian" | |
voices[Amy]="Female/British_English/Amy" | |
voices[Russell]="Male/Australian_English/Russell" | |
voices[Nicole]="Female/Australian_English/Nicole" | |
for voice in "${!voices[@]}" | |
do | |
lowerVoice=${voice,,} | |
voicePrefix=${voices[$voice],,} | |
voiceFilename=${voicePrefix//\//_} | |
for i in "${!array[@]}" | |
do | |
text=${array[$i]} | |
filename=${text// /_} | |
fileprefix=${filename,,} | |
filename="${filename,,}.mp3" | |
path="polly/by_voice/$voicePrefix/$filename" | |
if [ ! -d "polly/by_voice/$voicePrefix" ]; then | |
mkdir -p "polly/by_voice/$voicePrefix" | |
echo "Making dir: ./polly/by_voice/$voicePrefix" | |
fi | |
if [ ! -d "polly/by_statement/$fileprefix" ]; then | |
mkdir -p "polly/by_statement/$fileprefix" | |
echo "Making dir: ./polly/by_statement/$fileprefix" | |
fi | |
# Generate the voice files from Polly | |
if [ ! -f $path ]; then | |
cmd="aws polly synthesize-speech --output-format mp3 --voice-id $voice --text \"$text\" $path" | |
eval $cmd | |
echo "Command: $cmd" | |
echo "path: $path" | |
echo "filename: $filename" | |
echo "TTS: $text" | |
else | |
echo "$filename already exists" | |
fi | |
# Organize by statement as well | |
statementPath="polly/by_statement/$fileprefix/$voiceFilename.mp3" | |
if [ ! -f $statementPath ]; then | |
cp $path $statementPath | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment