You can now use AWS Polly with FreePBX Text to Speech!
Access your instance via SSH and execute the following command to run the installation script:
smartupgrade install-pollytts
*** Please note that SmartUpgrade is a utility unique to AWS FreePBX from TheWebMachine Networks. If you got here by searching the internet and are not using AWS FreePBX from TheWebMachine Networks, you can still use our install-pollytts script and AWS Polly for TTS by running the following command from the root console of your FreePBX server. You do still need to have a valid AWS Account in order to use AWS Polly:
curl https://files.thewebmachine.net/install-pollytts.sh | bash
Towards the end of the installation, you will be asked for the following information:
AWS Access Key ID
AWS Secret Access Key You can generate these keys from the AWS IAM Management Console: https://console.aws.amazon.com/iam/home
AWS Region Code Use the region closest to your server for optimal performance; will default to ‘us-east-1’ if not specified. Here’s a list of proper region codes: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions
AWS Polly Voice ID Will default to ‘Joanna’ (en-US) if not specified. Use a Voice ID from this page: https://docs.aws.amazon.com/polly/latest/dg/voicelist.html
Once the script is finished, you’ll want to add the ‘polly’ engine via Settings > Text to Speech Engines and specify ‘/usr/bin/node’ as the Engine Path:
Please be advised of the following limitations when using the AWS Polly engine to create TTS elements:
You CANNOT use single quotes/apostrophe (’) including contractions (use dont instead of don’t), double quotes ("), or carriage returns/newlines in your spoken text. Any of these (and possibly other special chars) will break the playback and you will get either only a partial audio file or no audio at all. Polly will automatically pronounce contractions without an apostrophe (like dont) correctly
You CANNOT use SSML at this time because the FreePBX TTS module does not support it. We are working with Sangoma to rebuild the entire TTS module to "modernize" it and bring additional capabilities like this...but we are a long way from that goal
AWS Polly has a 3000-character limit per API request. If you send more than this in a single TTS element, you will get no audio. If you need to provide spoken word longer than 3000-chars, simply break it down into multiple TTS elements and string them together in sequence within your dialplan (Part1 Destination -> Part2; Part2 Destination -> Part3, etc)
NOTE: You CAN use Asterisk Channel Variables in your TTS elements, which can greatly expand the variability of the elements you create. You can use variables like ${CALLERID(name)} to say the Caller's name or you can ensure you just speak the Caller's first name using the CUT function like this: ${CUT(CALLERID(name), ,1)} (there is a space between the two comas, which is the delimiter)
That’s it! Now you may create new TTS elements in Applications > Text to Speech and select ‘polly’ as the engine to use. FINAL NOTES ABOUT AWS POLLY:
AWS gives customers 5 million characters per month for free for the first 12 months, starting from your first request. You pay for usage beyond that ($4 per million chars). The way the TTS module is currently written, your TTS audio files are preserved in /var/lib/asterisk/sounds/tts/ after the first time they are encoded. So long as that TTS element text field remains unchanged AND you are NOT using Asterisk Channel Variables in the elements (which are dynamically generated during each call), no additional requests will be made to Polly for that TTS element. AWS Polly Pricing: https://aws.amazon.com/polly/pricing/
If you ever want to change which AWS Polly voice you are using, simply run install-pollytts again and select a new voice. You'll be asked if you want to delete all existing TTS audio to regenerate elements in the new voice