Created
February 27, 2019 11:00
-
-
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
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
#!/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