Claim your Biolink Click Here
0 like 0 dislike
2.9k views
How to use text to speech in asterisk using google?
in Education & Reference by (4.7k points) | 2.9k 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.

Dependencies
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.

Install
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.

Usage
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.

STEPS

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
 ./configure
 make
 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)
by (1.6k points)
0 0
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
asked Jul 7, 2014 in Education & Reference by Bhoomika (-30 points) | 27.4k views
0 like 0 dislike
1 answer
1 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.6k points) | 1.6k views
2 like 0 dislike
2 answers
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

1,310 questions
1,471 answers
569 comments
4,809 users