This script makes use of Google Translate API v2 to translate text strings and return them as channel variables. See the README for project documentation and Google's supported languages list for available languages.
Perl: The Perl Programming Language
perl-libwww: The World-Wide Web library for Perl
perl-libjson: Module for manipulating JSON-formatted data
IO-Socket-SSL: Perl module that implements an interface to SSL sockets
URI: Perl module for URI handling and escaping
API key from Google
Internet access in order to contact Google and get the language data.
To install, copy googletranslate.agi to your agi-bin directory.
Usually this is /var/lib/asterisk/agi-bin/
To make sure, check your /etc/asterisk/asterisk.conf file
Set your Google API key as the value of $appid in googletranslate.agi.
agi(googletranslate.agi,"text",[target language],[source language]): The text string will be sent to Google Translate for translation to the target language. The translated text will be stored as a channel variable named 'gtranslation'. The source language setting is optional; if it is not set, the translator engine will try to auto-detect it. If both the target and source languages are omitted, the script performs language detection on the given text string and returns the language code as the value of the channel variable 'glang'.
Asterisk dialplan examples:
;Translate a text string from English to French:
exten => 1234,1,agi(googletranslate.agi,"This is some random text.",fr)
exten => 1234,n,Verbose(1,Translated text: ${gtranslation})
;Translate from Greek to German:
exten => 1234,1,agi(googletranslate.agi,"Αυτό είναι ένα απλό τέστ στα ελληνικά.",de)
exten => 1234,n,Verbose(1,Translated text: ${gtranslation})
;Translate from Japanese to English:
exten => 1234,1,agi(googletranslate.agi,"これは、日本の簡単なテストです。良い一日を。",en)
exten => 1234,n,Verbose(1,Translated text: ${gtranslation})
;Translate a string into many languages:
exten => 1235,1,Set(MYTEXT="This is some random text for translation.")
exten => 1235,n,agi(googletranslate.agi,"${MYTEXT}",it)
exten => 1235,n,Verbose(1,In Italian: ${gtranslation})
exten => 1235,n,agi(googletranslate.agi,"${MYTEXT}",fr)
exten => 1235,n,Verbose(1,In French: ${gtranslation})
exten => 1235,n,agi(googletranslate.agi,"${MYTEXT}",ja)
exten => 1235,n,Verbose(1,In Japanese: ${gtranslation})
exten => 1235,n,agi(googletranslate.agi,"${MYTEXT}",es)
exten => 1235,n,Verbose(1,In Spanish: ${gtranslation})
;Detect text language:
exten => 1236,1,Set(MYTEXT="This is some random text for detection.")
exten => 1236,n,agi(googletranslate.agi,"${MYTEXT}")
exten => 1236,n,Verbose(1,Detected language: ${glang})
The googletranslate script for Asterisk is distributed under the GNU General Public License v2.
Lefteris Zafiris (zaf@fastmail.com)
You can get the latest stable version here.
Development snapshots are available in either ZIP or TAR format.
You can also clone the project with Git by running:
$ git clone https://github.com/zaf/asterisk-googletranslate.git
Speech recognition for Asterisk
GoogleTTS text to speech script for
Asterisk
Text translation using Microsoft Translator API
for Asterisk
Speech synthesis using Microsoft Translator
API for Asterisk
Asterisk Flite text to speech module
Asterisk e-Speak text to speech module