I have created a simple test script that will dial an extension and deliver a message. Its working fine. It dials an extension and plays an audio file.
Can someone point me to a guide or commands which will dial an extension and instead of playing an audio file, it will read out a message using TTS – something like “Extension 1001 is not reachable”. I need something basic, nothing fancy. This is for notifications & alerts.
[custom-ext-not-reachable]
exten => _.,1,Noop(Entering user defined context custom-ext-not-reachable in extensions_custom.conf)
exten => _.,n,flite(Extension ${EXTEN} is not reachable)
exten => _.,n,Hangup()
Then originate the call to
Application: Extension
context: custom-ext-not-reachable
exten: 1001
priority: 1
I’m on mobile, but you can look up how to set a channel var in the script with the content of the TTS message, and then reference that var in the dialplan.
Thanks again. From what I read on multiple forums, the approach is:
(1) Setup TTS in FreePBX.
I think I’ve done this. Settings > TTS Engine > Flite > Path = /usr/bin/flite
(2) In AMI Script create a variable with the message
Thats should be simple: $myMessage = “Reminder, PTM at 10:00 AM today”;
(3) Parse this variable to FLITE and get an audio file converted
(4) use this audio file in the AMI Script here: fputs($socket, “Data: silence/1&tt-weasels\r\n\r\n”);
replace “silence/1&tt-weasels” with result from (3)
I’m unable to get (3) to work. I guess once I resolve (3) I’ll be good to go.
I did some experimenting…
from extensions_custom.conf, I commented the last line: exten => _.,n,Hangup()
Reloaded the dial plan and executed the PHP script & I got the following on the console.
Asterisk 16.6.2, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 16.6.2 currently running on ast (pid = 2447)
-- Called 1020
== Using SIP RTP Audio TOS bits 184
== Using SIP RTP Audio TOS bits 184 in TCLASS field.
== Using SIP RTP Audio CoS mark 5
-- PJSIP/1020-00000adc is ringing
-- PJSIP/1020-00000adc is ringing
> 0x7f86003972a0 -- Strict RTP learning after remote address set to: 10.9.169.200:4004
-- PJSIP/1020-00000adc answered
> Launching Playback() on PJSIP/1020-00000adc
[2020-05-06 07:17:05] WARNING[26941]: app_playback.c:452 playback_exec: Playback requires an argument (filename)
I tried the below code again.
I get a call from extn 1022 to extn 1020. As soon as I answer, the call disconnects.
I’m hoping / expecting it to be a minor issue, not sure what.
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 10);
if (!$socket)
{
echo "$errstr ($errno)\n";
}
else
{
fputs($socket, "action: login\r\n");
fputs($socket, "username: admin\r\n");
fputs($socket, "secret: xxxxxxxx\r\n\r\n");
fputs($socket, "Action: Originate\r\n");
fputs($socket, "Channel: PJSIP/1020\r\n"); // Extension or Number to DIAL
fputs($socket, "Exten: 1022\r\n");
fputs($socket, "Timeout: 30000\r\n"); // (30 sec) in msec
fputs($socket, "Async: true\r\n"); // for faster dialout
fputs($socket, "CallerID: 1022 <1022>\r\n"); // No space in callerID name
fputs($socket, "Application: flite\r\n");
fputs($socket, "Data: Welcome to hello world\r\n");
fputs($socket, "\r\n");
$wrets = fgets($socket,128);
fputs($socket, "Action: Logoff\r\n\r\n");
}
If your OK with flite’s quality, then yum update; fwconsole restart as suggested in the other thread.
Otherwise you can use the command line flite to generate a wav file and convert it for use in playback. Googling “asterisk play wav file” should give you the needed info.
Not much to pick from in the distro repo’s. I don’t think the distro flite includes any additional voices. Festival does (slt is probably the best voice). All the tts versions in the repo are outdated.
The clearest command line tts is picotts IMO. Some of the better(newer than the distro) espeak voices are arguably a little less “electronic” but muddy/slurry/drunk sounding in comparison IMO. I don’t know of a centos based picotts package(haven’t looked very hard), but you can get the debian binaries running under the distro.
People ask why some of us don’t use the distro. This is a small example.
If you go the commercial route, there are some other options like Cepstral, but skip those and go with a web api provider.
The better Google/IBM/MS/Amazon voices can be hard to recognize as artificial, but require respective accounts (free or almost free for lite usage).
I totally get it now. Slightly off topic, is there a tool to migrate all FreePBX & Asterisk settings from one server to another?
I’ll check this out, my requirement is just about 2-3 TTS per month. I’m sure I’ll be covered with a free account. I’m sorted if these big boys offer CLI.