0 like 0 dislike
How to use text to speech in asterisk using google?
asked Feb 7 in Education & Reference by Marc (2,480 points) | 107 views

1 Answer

0 like 0 dislike

This script makes use of Google's translate 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.

This TTS service is 'unofficial' and not supported by Google, it can be terminated at any point with no warning. People looking for TTS solutions to base their projects/products on should look for alternative, officially supported services.

perl : The Perl Programming Language
perl-libwww : The World-Wide Web library for Perl
Perl-Crypt-SSLeay or perl-IO-Socket-SSL for SSL/TLS encryption
sox : Sound eXchange, sound processing program
mpg123 : MPEG Audio Player and decoder
format_sln : Raw slinear module for asterisk
Internet access in order to contact google and get the voice data.

To install copy googletts.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(googletts.agi,text,[language],[intkey]): This will invoke the Google 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 google'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.


yum install perl
 yum install perl-libwww-perl
 yum install sox
 wget https://sourceforge.net/projects/mpg123/files/mpg123/1.25.8/mpg123-1.25.8.tar.bz2
 tar xvjf mpg123-1.25.8.tar.bz2
 cd mpg123-1.25.8
 make install
 ln -s /usr/local/bin/mpg123 /usr/bin/mpg123

Asterisk dialplan example:

 exten => 1234,1,Answer()
  ;;Play mesage in Hindi:
exten => 1234,n,agi(googletts.agi,"विकास अच्छा लड़का है और मेरा नाम धूप है, मैं Google में काम नहीं करता",hi)
  ;;Play mesage in English:
exten => 1234,n,agi(googletts.agi,"This is a test working at all. I dont know thanks so much.",en)
  ;;Play message in Spanish:
exten => 1234,n,agi(googletts.agi,"Esta es una simple prueba en español.",es)
  ;;Play message in Greek:
exten => 1234,n,agi(googletts.agi,"Αυτό είναι ένα απλό τέστ στα ελληνικά.",el)
  ;;Play message in Japanese:
exten => 1234,n,agi(googletts.agi,"これは、日本の簡単なテストです。良い一日を。",ja)
  ;;Play message in simplified Chinese:
exten => 1234,n,agi(googletts.agi,"这是一个简单的测试,在中国。有一个愉快的一天。",zh-CN)
answered Feb 7 by Sam (1,420 points)
to install googletts.agi

You can also clone the project with Git by running:

$ git clone git://github.com/zaf/asterisk-googletts

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Sep 24, 2017 in Education & Reference by Sam (1,420 points) | 372 views
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

Mathe Forum Schule und Studenten
1,161 questions
1,297 answers
1,558 users