0 like 0 dislike
43 views
How to use text to speech in asterisk using google?
asked Feb 7 in Education & Reference by Marc (2,490 points) | 43 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)
answered Feb 7 by Sam (1,470 points)

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
asked Sep 24, 2017 in Education & Reference by Sam (1,470 points) | 293 views
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
1 like 0 dislike
1 answer
asked Jul 5, 2014 in Education & Reference by Bhoomika (50 points) | 49 views

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,151 questions
1,281 answers
263 comments
1,509 users