[asterisk-users] AGI script that uses google's text to speech engine

Lefteris Zafiris zaf.000 at gmail.com
Thu Dec 1 11:44:43 CST 2011


On Thu, 01 Dec 2011 17:23:59 +0000
Kingsley Tart <kingsley at skymarket.co.uk> wrote:

> Hi. Aside from converting spaces to plus signs, you don't encode any
> special characters before putting them in the URL. It might be safer
> to run $line through some sort of encoding before calling Google with
> it, even if most special characters probably don't result in any
> sound. Google say "and" if you give it an ampersand, but unescaped
> you couldn't include that in the string.
> 
> You may decide to have an option to locally cache pre-produced sound
> files in case that phrase is used again.
> 
> Cheers,
> Kingsley.
> 

Thanks for the suggestion. Ther's already some sort of input sanitation:
 $AGI{arg_1} =~ s/[\\\/|*~<>^\(\)\[\]\{\}\n\r]/ /g;
that strips most special characters but i guess it needs some more work.
As for the caching the script supports it already, its enabled by
default and controlled by these 2 variables in the script:
 $usecache   = 1;
 $cachedir   = "/tmp";
Voice data gets stored in the cachedir for future use so we don't have
to fetch it from google each time.

----------------
Lefteris Zafiris



More information about the asterisk-users mailing list