Skip to content

Instantly share code, notes, and snippets.

@garethbowker
Created February 27, 2019 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethbowker/e3192d67f4efb82c8737b7288b28764c to your computer and use it in GitHub Desktop.
Save garethbowker/e3192d67f4efb82c8737b7288b28764c to your computer and use it in GitHub Desktop.
Iterate through txt files, upload to AWS Polly to create MP3 files using tts
#!/bin/bash
# Available voices at: https://docs.aws.amazon.com/polly/latest/dg/voicelist.html
VOICE=Vitoria
#VOICE=Ricardo
OUTPUT="${PWD}/mp3"
mkdir -p "${OUTPUT}"
for f in *.txt; do
# FILE is set to the filename, replacing .txt with .mp3
# and is places inside the $OUTPUT directory
FILE="${OUTPUT}/${f%.txt}.mp3"
if [ -e "${FILE}" ]; then
echo "Skipping ${f} - MP3 already exists"
else
# Note: Lexicons must have been pre-loaded into AWS Polly
tts "$f" "${FILE}" --voice ${VOICE} --lexicon brPTacronyms --lexicon brPTwords --lexicon brPTwords2
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment