Skip to content

Instantly share code, notes, and snippets.

@nivex
Created March 28, 2019 16:39
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 nivex/d03754dc5bad060fc64c162b7954a7ee to your computer and use it in GitHub Desktop.
Save nivex/d03754dc5bad060fc64c162b7954a7ee to your computer and use it in GitHub Desktop.
AGI for high quality Festival TTS
#!/bin/bash
###
# AGI for high quality Festival TTS
# kjotte 2019-03-23
#
# The Asterisk built-in Festival application only operates at 8KHz.
# This script implements a 32KHz HTS voice.
#
# Sample invocation from dialplan:
# AGI("festival-hts","Hello. I am not a robot.")
#
# Packages required:
# - festival
# - festvox-us-slt-hts
###
# Consume all variables sent by Asterisk
while read VAR && [ "${VAR}" != "" ] ; do : ; done
# Create temp file
TMPFILE=$(mktemp /tmp/festival-XXXXXX.sln32)
# Generate waveform
echo "$1" | text2wave -eval "(voice_cmu_us_slt_arctic_hts)" -otype raw -scale 1.5 > ${TMPFILE}
# Tell Asterisk to play it
TMPWAVE=$(echo ${TMPFILE} | sed 's/\.sln32$//')
echo STREAM FILE ${TMPWAVE} \"\"
read # We shoud probably do something with this response
# Clean up
rm ${TMPFILE}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment