Thursday, June 2, 2016

Asterisk PBX and IBM Watson Text to Speech

Evaluating IBM Watson Text to Speech API with Asterisk PBX. Using a Bash script to create and format the recording. Script uses curl and avconv commands. This is running on Ubuntu 14.04 with Asterisk 11.7.0.

Dial plan snippet /etc/asterisk/extensions.conf

[PremiseVisitSurvey]
exten => s,1(StartPremiseVisitSurvey),Wait(0.3)
same => n,Set(text0=This is ABC Company with a five question survey about your recent service visit. After each question, press 1 for yes, or press 2 for no.)
same => n,Set(randomNumber=${RAND()})
same => n,agi(tts_ibm.sh)
same => n,Set(text0=Did your recent ABC Company service visit meet your satisfaction?)
same => n,agi(tts_ibm.sh)
same => n,Playback(beep)
same => n,Read(response,,1)
same => n,System(/opt/scripts/postIvrResponse.sh ${phoneNumber} ${CONTEXT}_1_${randomNumber} ${response} ${accountNumber} ${orderNumber})
same => n,Set(text0=Were you satisfied with the timeliness of the service?)
same => n,agi(tts_ibm.sh)
same => n,Playback(beep)
same => n,Read(response,,1)
same => n,System(/opt/scripts/postIvrResponse.sh ${phoneNumber} ${CONTEXT}_2_${randomNumber} ${response} ${accountNumber} ${orderNumber})
same => n,Set(text0=Were you satisfied with the quality of the service?)
same => n,agi(tts_ibm.sh)
same => n,Playback(beep)
same => n,Read(response,,1)
same => n,System(/opt/scripts/postIvrResponse.sh ${phoneNumber} ${CONTEXT}_3_${randomNumber} ${response} ${accountNumber} ${orderNumber})
same => n,Set(text0=Was the ABC Company technician knowledgeable and professional?)
same => n,agi(tts_ibm.sh)
same => n,Playback(beep)
same => n,Read(response,,1)
same => n,System(/opt/scripts/postIvrResponse.sh ${phoneNumber} ${CONTEXT}_4_${randomNumber} ${response} ${accountNumber} ${orderNumber})
same => n,Set(text0=Would you like a follow-up call to discuss your responses to this survey?)
same => n,agi(tts_ibm.sh)
same => n,Playback(beep)
same => n,Read(response,,1)
same => n,System(/opt/scripts/postIvrResponse.sh ${phoneNumber} ${CONTEXT}_5_${randomNumber} ${response} ${accountNumber} ${orderNumber})
same => n,Set(text0=Thank you. Good bye.)
same => n,agi(tts_ibm.sh)
same => n,hangup()