zaf / asterisk-googletts

Asterisk AGI script that uses Google's translate text to speech service.
GNU General Public License v2.0
212 stars 125 forks source link

No text read after commas #12

Closed jeetzz closed 10 years ago

jeetzz commented 10 years ago

Hi,

Firstly, thanks for all the effort you put in creating this agi, awesome!

The script runs perfect when called from a dial-plan, however I have an issue. Whenever I put any commas in the text, then the next part of the sentence after comma is not read or recognized by googletts. I am using following to execute the agi. Works fine: $agi->exec("AGI","googletts.agi,\"Hello my name is Tina!\",en");

Text after comma is not recognized: $agi->exec("AGI","googletts.agi,\"Hello, I am Asterisk! I attend all your calls, you will never need anyone else.\",en");

Please provide some help in this regards. Thanks.

zaf commented 10 years ago

Hello, I see that you are actually calling it from within another AGI script, and it also looks like a perl script. At first it might worth trying to integrate the googletts code in your script, it will make things a lot more easier and reduce the overhead. You can either use something like this module: https://metacpan.org/pod/Speech::Google::TTS or try to integrate the code of asterisk-googletts in your code (as long as the licensing is compatible). Apart from that, and to return to the actual issue, it seems that asterisk itself is not parsing the arguments that are passed by agi to app exec correctly, if you have a look at parse_args() in res_agi.c you will realize how buggy it is. As a temporary fix try some funny escaping like: "AGI","googletts.agi,\"Hello\\, I am Asterisk! I attend all your calls\\, you will never need anyone else.\",en" This is unfortunately an asterisk issue, not something googletts AGI script can handle itself.

jeetzz commented 10 years ago

Hi Zaf,

Thanks a lot for your reply, please accept my apology for not being clear enough. Yes I am calling it from within another script, but its not a perl script, its a php AGI script. I would have certainly used the trick provided by you above for escaping, however my problem is the data that is being called by the googletts is fetched from the database server and is randomn hence I cannot predict the commas. I am certainly looking forward to integrate googletts with my agi script. I would highly appreciate if you could provide some assistance/pointers in this regards.

Thanks a lot once again.

zaf commented 10 years ago

I'm not familiar with your code but I guess it would be easy to add a function that will take the strings you want to pass to the AGI app and escape the comas as needed.

I was wrong to assume you were using perl, the syntax looked exactly the same as with the Asterisk::AGI perl module :) Regarding integrating the googletts functionality in your script, the actual code is here, feel free to study it and if you have some specific questions I would be glad to help.

jeetzz commented 10 years ago

Thanks a lot Zaf, I appreciate your help! I used exactly what you mentioned. I added a function to clean all special characters in the string. Has solved my problem!

Must say you are doing a great job helping others achieve their goals! Thanks!