#!/bin/bash -f
#
# PODNAME: awspollyogg
# ABSTRACT: script converting textfile named $1
#                               into oggfile $2
#                          with engine:voice $3
#           using AWS Polly

# check arguments
if [ "$#" -ne 3 ]; then
    echo "Usage: $0 <input_text_file> <output_ogg_file> <engine:voice>"
    exit 1
fi

# Settings and validate engine and voice
SETTINGS=(${3//:/ })

# Run polly, run!
aws polly synthesize-speech --output-format ogg_vorbis \
    --engine ${SETTINGS[0]} --voice-id ${SETTINGS[1]} \
    --text "`cat $1`" $2 > /dev/null
