This script makes use of MS Translator text to speech service in order to render text to speech and play it back to the user. It supports a variety of different languages (See README for a complete list), local caching of the voice data and also supports 8kHz or 16kHz sample rates to provide the best possible sound quality along with the use of wideband codecs.
perl : The Perl Programming Language
perl-libwww : The World-Wide Web library for Perl
sox : Sound eXchange, sound processing program
Internet access in order to contact MS and get the voice data.
In order to use this script you have to subscribe to the Microsoft
Translator API on Azure Marketplace
and register your application with Azure DataMarket.
Existing Bing API Keys
still work but they are considered deprecated By Microsoft.
To install copy mstts.agi to your agi-bin directory.
Usually this is /var/lib/asterisk/agi-bin/
To make sure check your /etc/asterisk/asterisk.conf file.
agi(mstts.agi,text,[language],[intkey]): This will invoke the MS Translator TTS engine, render the text string to speech and play it back to the user. If 'intkey' is set the script will wait for user input. Any given interrupt keys will cause the playback to immediately terminate and the dialplan to proceed to the matching extension (for use in IVR). The script contacts microsoft's TTS service in order to get the voice data which then stores in a local cache (by default /tmp/) for future use. Parameters like default language, use of cache and cache dir can be set up by the user.
Asterisk dialplan example:
;MsTTS Demo exten => 1234,1,Answer() ;;Play mesage in English: exten => 1234,n,agi(mstts.agi,"This is a simple text to speech synthesis test in english.",en) ;;Play message in Spanish: exten => 1234,n,agi(mstts.agi,"Esta es una simple prueba en español.",es) ;;Play message in Japanese: exten => 1234,n,agi(mstts.agi,"これは、日本の簡単なテストです。良い一日を。",ja) ;;Play message in simplified Chinese: exten => 1234,n,agi(mstts.agi,"这是一个简单的测试,在中国。有一个愉快的一天。",zh-cn)
;A simple dynamic IVR using MsTTS [my_ivr] exten => s,1,Answer() exten => s,n,Set(TIMEOUT(digit)=5) exten => s,n,agi(mstts.agi,"Welcome to my small interactive voice response menu.",en) ;;Wait for digit: exten => s,n(start),agi(mstts.agi,"Please dial a digit.",en,any) exten => s,n,WaitExten() ;;PLayback the name of the digit and wait for another one: exten => _X,1,agi(mstts.agi,"You just pressed ${EXTEN}. Try another one please.",en,any) exten => _X,n,WaitExten() exten => i,1,agi(mstts.agi,"Invalid extension.",en) exten => i,n,goto(s,start) exten => t,1,agi(mstts.agi,"Request timed out.",en) exten => t,n,goto(s,start) exten => h,1,Hangup()
The MS Translator TTS script for asterisk is free software distributed under the GNU General Public License version 2
Lefteris Zafiris (zaf@fastmail.com)
Develompent snapshots are available in either zip or tar formats.
A version that supports the new Bing Speech Speech API can be downloaded here.
You can also clone the project with Git by running:
$ git clone git://github.com/zaf/asterisk-mstts
Speech recognition for
Asterisk
Text translation using Goole Translate API
for asterisk
Text translation using Microsoft Tranlsator API
for asterisk
Speech synthesis using Google voice API for
Asterisk
Asterisk Flite text to speech module
Asterisk e-Speak text to speech module