KUMARULLAL
Guru
- Joined
- Feb 20, 2008
- Messages
- 243
- Reaction score
- 28
Thanks for the work around lzaf. No more errors.
Has anyone tried out lzaf's googletts script that uses google's text to speech? I am curious to know if the quality of speech is any better than flite?
wget ftp://195.220.108.108/linux/dag/redhat/el5/en/i386/dag/RPMS/mpg123-1.9.1-1.el5.rf.i386.rpm
yum install libesd.so.0
yum install sox
yum install perl-libwww-perl
yum install perl-XML-Simple
wget --no-check-certificate https://github.com/downloads/zaf/asterisk-googletts/asterisk-googletts-0.5.tar.gz
-----
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, enabling or disabling caching and cache dir
can be set up by editing the script.
--------
Examples
--------
sample dialplan code for your extensions.conf
;GoogleTTS Demo
;PLayback messages to user
exten => 1234,1,Answer()
;;Play mesage in English:
exten => 1234,n,agi(googletts.agi,"This is a simple google text to speech test in english.",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)
;A simple dynamic IVR using GoogleTTS
[my_ivr]
exten => s,1,Answer()
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,agi(googletts.agi,"Welcome to my small interactive voice response menu.",en)
;;Wait for digit:
exten => s,n(start),agi(googletts.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(googletts.agi,"You just pressed ${EXTEN}. Try another one please.",en,any)
exten => _X,n,WaitExten()
exten => i,1,agi(googletts.agi,"Invalid extension.",en)
exten => i,n,goto(s,start)
exten => t,1,agi(googletts.agi,"Request timed out.",en)
exten => t,n,goto(s,start)
exten => h,1,Hangup()
-------------------
Supported Languages
-------------------
"af" Afrikaans, "sq" Albanian, "am" Amharic, "ar" Arabic, "hy" Armenian, "az" Azerbaijani,
"eu" Basque, "be" Belarusian, "bn" Bengali, "bh" Bihari, "bs" Bosnian, "br" Breton, "bg" Bulgarian,
"km" Cambodian, "ca" Catalan, "zh-CN" Chinese (Simplified), "zh-TW" Chinese (Traditional),
"co" Corsican, "hr" Croatian, "cs" Czech, "da" Danish, "nl" Dutch, "en" English, "eo" Esperanto,
"et" Estonian, "fo" Faroese, "tl" Filipino, "fi" Finnish, "fr" French, "fy" Frisian, "gl" Galician,
"ka" Georgian, "de" German, "el" Greek, "gn" Guarani, "gu" Gujarati, "xx-hacker" Hacker, "ha" Hausa,
"iw" Hebrew, "hi" Hindi, "hu" Hungarian, "is" Icelandic, "id" Indonesian, "ia" Interlingua, "ga" Irish,
"it" Italian, "ja" Japanese, "jw" Javanese, "kn" Kannada, "kk" Kazakh, "rw" Kinyarwanda,
"rn" Kirundi, "xx-klingon" Klingon, "ko" Korean, "ku" Kurdish, "ky" Kyrgyz, "lo" Laothian,
"la" Latin, "lv" Latvian, "ln" Lingala, "lt" Lithuanian, "mk" Macedonian, "mg" Malagasy,
"ms" Malay, "ml" Malayalam, "mt" Maltese, "mi" Maori, "mr" Marathi, "mo" Moldavian, "mn" Mongolian,
"sr-ME" Montenegrin, "ne" Nepali, "no" Norwegian, "nn" Norwegian (Nynorsk), "oc" Occitan, "or" Oriya,
"om" Oromo, "ps" Pashto, "fa" Persian, "xx-pirate" Pirate, "pl" Polish, "pt-BR" Portuguese (Brazil),
"pt-PT" Portuguese (Portugal), "pa" Punjabi, "qu" Quechua, "ro" Romanian, "rm" Romansh, "ru" Russian,
"gd" Scots Gaelic, "sr" Serbian, "sh" Serbo-Croatian, "st" Sesotho, "sn" Shona, "sd" Sindhi,
"si" Sinhalese, "sk" Slovak, "sl" Slovenian, "so" Somali, "es" Spanish, "su" Sundanese, "sw" Swahili,
"sv" Swedish, "tg" Tajik, "ta" Tamil, "tt" Tatar, "te" Telugu, "th" Thai, "ti" Tigrinya, "to" Tonga,
"tr" Turkish, "tk" Turkmen, "tw" Twi, "ug" Uighur, "uk" Ukrainian, "ur" Urdu, "uz" Uzbek,
"vi" Vietnamese, "cy" Welsh, "xh" Xhosa, "yi" Yiddish, "yo" Yoruba, "zu" Zulu.
-------
License
-------
The GoogleTTS script for asterisk is distributed under the GNU General Public
License v2. See COPYING for details.
For some reason, googletts AGI cannot process text in foo variable (/tmp/results.txt). I see that the value has been passed in asterisk log file and even see *.sln file in temp folder but it does not play back. Any suggestions?.
exten => 444,1,Answer()
exten => 444,n,Wait(1)
exten => 444,n,agi(googletts.agi,"As Rick Perry would say, Ooops! Something went haywire. Please try your call again later.",en)
exten => 444,n,hangup
Thanks for your feedback. I have, however, tried putting plain sentence without any punctuation on result.txt file and then pass that file as variable, but still not getting anywhere. Here is the piece of code from extension_custom.conf file:The idea of passing a text file as input to an agi script has some shortcomings. Newlines, quotes and some special characters might confuse the agi script and the way it handles stdin to get its arguments. As a first step i would suggest you to strip newlines and quotes from your text (results.txt) before passing it to googletts.agi
Thanks Ward. The text enclosed in quotes work fine. I was trying to pass it as a variable to read content of result.txt file.Code:exten => 444,1,Answer() exten => 444,n,Wait(1) exten => 444,n,agi(googletts.agi,"As Rick Perry would say, Ooops! Something went haywire. Please try your call again later.",en) exten => 444,n,hangup
If this code doesn't work, then you're missing one or more of the dependencies. sox or mpg123 are likely culprits. HINT: There are no problems on default PIAF2 systems.
when I try to pass on a number, instead of reading it out as a whole number (one thousand five hundred and forty five), it reads out the individual digits.
exten => 444,n,agi(googletts.agi,"8 4 3:,1:2:3:,4:5:6:7",en)
Hi,
Anyway that asterisk-speech-recog script will take both key in digit and voice input as well. And maybe, some magic words that make script process right away like when you say Yes, No, or Stop...
The only thing that I can think of is a silence timeout. Is that feasible? Is silence in a phone audio stream difficult to define or detect?
; Wolfram Alpha Dialplan Interface for PIAF2 servers
exten => 4748,1,Answer()
exten => 4748,2,Wait(1)
exten => 4748,3,Set(calledbefore=${DB_EXISTS(blacklist/${CALLERID(num)})
exten => 4748,4,Noop(${CALLERID(num)})
exten => 4748,5,Noop(${calledbefore})
exten => 4748,6,GotoIf($["foo${calledbefore}" = "foo1"]?11:51)
exten => 4748,7,Goto(90)
exten => 4748,10,Set(removed=${DB_DELETE(blacklist/${CALLERID(num)/${CALLERID(num)})})
exten => 4748,11,Flite("Hi. Thanks for calling. We're very sorry. In order to give everyone an opportunity to try this service, we've had to limit calls to one call per person: You still can beat the system. Just call back from a different phone number. Have a great day. Good bye.")
exten => 4748,12,Goto(91)
exten => 4748,50,Set(DB(blacklist/${CALLERID(num)})=${CALLERID(num))
exten => 4748,51,swift("Seriously,, After the beep, Say your question, then Press the pound key, or remain quiet.")
exten => 4748,52(record),agi(speech-recog.agi,en-US)
exten => 4748,53,Noop(= Script returned: ${status} , ${id} , ${confidence} , ${utterance} =)
exten => 4748,54,swift("${utterance}")
exten => 4748,55,Background(vm-star-cancel)
exten => 4748,56,Background(continue-english-press)
exten => 4748,57,Background(digits/1)
exten => 4748,58,Read(PROCEED,beep,1,,1,3)
exten => 4748,59,GotoIf($["foo${PROCEED}" = "foo1"]?70)
exten => 4748,60,GotoIf($["foo${PROCEED}" = "foo"]?70:90)
exten => 4748,70,Set(DB(blacklist/${CALLERID(num)})=${CALLERID(num))
exten => 4748,71,Set(FILE(/tmp/query.txt)=${utterance})
exten => 4748,72,Background(one-moment-please)
exten => 4748,73,System(/var/lib/asterisk/agi-bin/4747)
exten => 4748,74,Set(foo=${FILE(/tmp/results.txt)})
exten => 4748,75,swift("${foo}")
exten => 4748,76,Goto(90)
exten => 4748,90,swift("Have a nice day! Good bye.")
exten => 4748,91,hangup
flac --best --sample-rate=8000 msg0000.wav -o msg0000.flac
speech-recog-cli.pl msg0000.flac | head -2 | tail -1 | cut -f 2 -d ":"
#!/usr/bin/perl
open(VOICEMAIL,"|/usr/sbin/sendmail -t");
open(LAMEDEC,"|/usr/bin/dos2unix|/usr/bin/base64 -di|/usr/local/bin/lame --quiet --preset voice - /var/spool/asterisk/tmp/vmout.$$.mp3");
open(VM,">/var/spool/asterisk/tmp/vmout.debug.txt");
my $inaudio = 0;
loop: while(<>){
if(/^\.$/){
last loop;
}
if(/^Content-Type: audio\/x-wav/i){
$inaudio = 1;
}
if($inaudio){
while(s/^(Content-.*)wav(.*)$/$1mp3$2/gi){}
if(/^\n$/){
iloop: while(<>){
print LAMEDEC $_;
if(/^\n$/){
last iloop;
}
}
close(LAMEDEC);
print VOICEMAIL "\n";
print VM "\n";
open(B64,"/usr/bin/base64 /var/spool/asterisk/tmp/vmout.$$.mp3|");
while(<B64>){
print VOICEMAIL $_;
print VM $_;
}
close(B64);
print VOICEMAIL "\n";
print VM "\n";
$inaudio = 0;
}
}
print VOICEMAIL $_;
print VM $_;
}
print VOICEMAIL "\.";
print VM "\.";
close(VOICEMAIL);
close(VM);
#CLEAN UP THE TEMP FILES CREATED
#This has to be done in a separate cron type job
#because unlinking at the end of this script is too fast,
#the message has not even gotten piped to send mail yet
Link up your team and customers Phone System Live Chat Video Conferencing
Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.
Check your inbox!
We’ve sent you an email. Click on the button in the email body to verify your email address – (if you can not find it, check your spam folder).
Upon verification you will be directed to the 3CX setup wizard.