FreePBX | Register | Issues | Wiki | Portal | Support

TTS Engine Custom - Amazon Polly - 24 languages


(Jerson Jr) #43

Try this:

})

let params = {
‘Text’: argv.text,
// ‘Text’: ‘Tatiana’,
‘OutputFormat’: ‘mp3’,
‘SampleRate’: ‘8000’,
‘VoiceId’: ‘Vitoria’
}

To

})

let params = {
‘Text’: argv.text,
// ‘Text’: ‘Tatiana’,
‘OutputFormat’: ‘mp3’,
‘SampleRate’: ‘8000’,
‘VoiceId’:argv.voice
}


#44

what does “argv.voice” actually do? Because i already changed it with a different speaker name in my second script. Do you want me to change it as it seems? If so, how could polly decide which speaker should be spoken?


#45

I am trying to use AWS-Polly but it seems I am doing something wrong or permissions issue somewhere. I followed install and create/modify script.js and propolys-tts to the letter of Jerson Jr/ William Bond. It trys to work because I see in my tts sound folder aws-polly-tts* wav, txt and mp3 files but not the sln file that my CLI says it is trying to play back. Also when I download and play back the mp3 and wav file they are blank. The text file has the text from my text to speech application. I only say it maybe a permissions issue because the files it does create does not have the group write permission like when I use the flite engine.


#46

Disregard, turns out the text to speech app had special characters in it. Everything works when I removed them.


(Jose Sanchez) #47

I get this error

node script.js --mp3=/var/lib/asterisk/sounds/mp3file --text=‘testando’ --wav=/var/lib/asterisk/sounds/wavfile

/opt/aws-nodejs-sample/script.js:15
let params = {
^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
root@erimat:/opt/aws-nodejs-sample#


(Jerson Jr) #48

node script.js --mp3=/var/lib/asterisk/sounds/test.mp3 --text=‘Hello’ --wav=/var/lib/asterisk/sounds/tts/test");


#49

I know its been said before, but this would be so useful as a module. Thanks @jersonjunior for keeping this alive.


(Andrew Nagy) #50

It’s up to jerson if he wants to do this.


(Dave Burgess) #51

From experience:

Doing the code is the easy part. Building it into a module is no small undertaking. I found the new object model daunting, and I’m not new to this programming thing. What I did that with the SCCP Manager on the old FreePBX (1.8 and before) was still a LOT of work. All of the new supporting code, packaging, BMO-interfacing, and GUI tricks make it a big effort and time investment for someone that only does this once. Even then, the project ends up in the repository as a “here you go, knock yourself out” piece of software.

Don’t get me wrong, I’d do that work again if I wasn’t working full time and running my own business. Having some teaming from the commercial folks for an “open” module would be really cool. Of course, how does one fund something like that? Sangoma’s people are paid to do this, so asking us to ask them isn’t really appropriate, and if Sangoma asks them to do it for free, there are labor rules about that…

A compromise solution might be to take James’ “basic” hello world starter kit and put together a webinar explaining how the pieces go together for us “wanna-be” module developers. Perhaps a clear path for “promotion” and (of course) the obligatory NDA/Release that Sangoma has all
developers sign might be a good first step.


(Andrew Nagy) #52

https://wiki.freepbx.org/display/FOP/FreePBX+Module+Generator


(Jerson Jr) #53

I would like to do this module, but I do not have the ability to perform this task, in the beginning I contacted the Sangoma people but the bureaucracy did not let things flow, anyway I believe that a simple change in the engine module could improve the module to operate with IBM Watson, Microsoft Bing and Amazon Polly. Modify the module so that it can write the entries in /var/lib/asterisk/agi-bin/propolys-tts.agi

Example:

case ‘node’:

                    exec($enginebin." /opt/aws-nodejs-sample/script.js --mp3=/var/lib/asterisk/sounds/tts/$engine-tts-$hash.mp3 --text='$text' --wav=/var/lib/asterisk/sounds/tts/$engine-tts-$hash");
                    break;

The remainder would be borne by the user, would already be a major breakthrough.


(Andrew Nagy) #54

Yes. here is the “bureaucracy” you speak of, where you copy and pasted code into an email and expected us to take that copy and pasted code (with HTML style formatting) and then build the module around it. I’m sorry but we do not have time for that. I don’t think (or I can’t think) of any project that will accept code submitted through the body of an HTML email message. I told you we wouldn’t accept this in this format and asked you to submit a pull request and you replied with “excuse me for the inconvenience!”. You then proceeded to create a ticket instead of an email (https://issues.freepbx.org/browse/FREEPBX-14505) with the same copy and pasted HTML message

I don’t think it’s an “inconvenience” to ask for you to make a Pull Request.


(Rob Thomas) #55

And it’s not like we didn’t try. We copied it as plain text, and that stripped out some of the formatting, but then some line wrapping broke other things, and after both of us spending about half an hour on it we gave up.

If you don’t know how to use git, there are plenty of online courses, or, you could even ask us directly in IRC (freepbx-devel or freepbx on freenode) for assistance.

But throwing a pile of half-written code over a wall and then walking away from it isn’t a good way to win friends or influence people 8-(


(Andrew Nagy) #56

One can signup on github. Fork the tts project and edit files inline in the browser. Then submit the code as a Pull Request back to FreePBX.

Find the tts repo on github: https://github.com/FreePBX/tts


(Jerson Jr) #57

My intention is not to cause confusion, at any moment I waited for Sangoma to do the work for me, I received your response and I asked my humble apologies for sending a supposed code that I was able to accomplish by modifying the TTS engine file, the intention was collaborate, I make it clear that I am not a developer, only a FreePBX user. At some point I had intention to attack you as I felt being exposed with my email here in this topic but I understand. But once I ask my humble apologies for sending the code via email and for not having the expertise to work with git.


(Andrew Nagy) #58

Your email that I posted is exactly the same as the publicly visible ticket you opened up at https://issues.freepbx.org/browse/FREEPBX-14505


(TheJames) #59

On a side note patching this is not the answer. This is 2018, the code has been patched together for 5 years.
image

This really needs to be refactored to be object orientated and “modular”
Something like:
tts\Modules\Poly\Tts.php
Having a module for each technology.
As it sits now there is no good way to do things like multiple languages or different voices where supported or have API keys when needed.
It also makes sense to have the option to “Generate a static sound” so you are not making an API call every time.

Someone could surely take this on as a project.
I recently did asteriskinfo as a side project if you want to see an example
https://git.freepbx.org/projects/FREEPBX/repos/asteriskinfo/browse?at=refs%2Fheads%2Frelease%2F15.0
The difference here would be wanting views which is why you would use a folder to organize.


(Manojprabhagar Mohan) #60

Hi , I am completely new to Freepbx as well as node js . I configure Amazon Polly by following above steps and can run it through cli and download the mp3 file in the specified folder but I need to know how can I use it in dialplan as well as call files is it possible?


(Manojprabhagar Mohan) #61

Can you please give the example dial plan or function how to execute it…?


#62

You can use it via the GUI in the Text To Speech Module. If you build it out via the GUI, you could also SSH to the conf file and see how its built out in the dial plan, after it is in the GUI.