-
-
Save sholtomaud/fd19b1472dac4f8f007925f061c7e42f to your computer and use it in GitHub Desktop.
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 | |
usage() { | |
echo "Usage: $0 [-v <Ruth|Matthew|Amy>]" 1>&2 | |
echo "Ruth : Female English (US) - Default" 1>&2 | |
echo "Matthew : Male English (US)" 1>&2 | |
echo "Amy : Female English (British)" 1>&2 | |
exit | |
} | |
while getopts ":v:" OPT; do | |
case "${OPT}" in | |
v) | |
VOICE=${OPTARG} | |
[ "${VOICE}" = "Ruth" ] || [ "${VOICE}" = Matthew ] || [ "${VOICE}" = Amy ] || usage | |
;; | |
*) | |
usage | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
if [ -z "${VOICE}" ]; then | |
VOICE="Ruth" | |
fi | |
TMP_TEXT_FILE=$(mktemp) | |
cat > ${TMP_TEXT_FILE} | |
cat ${TMP_TEXT_FILE} | |
TMP_VOICE_FILE=$(mktemp) | |
echo "Using ${VOICE} voice." | |
aws polly synthesize-speech --output-format mp3 --region us-east-1 \ | |
--text "$(cat ${TMP_TEXT_FILE})" \ | |
--voice-id ${VOICE} --engine generative ${TMP_VOICE_FILE} | |
afplay ${TMP_VOICE_FILE} | |
rm ${TMP_TEXT_FILE} ${TMP_VOICE_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment