Categories
Blog Design FreePBX Knowledge Base

Voice recognition and Asterisk.

This is primarily about Googles new Cloud Speech API and Asterisk recordings.

Having worked on many Voice rec systems including Mitels attendant system, Oranges Wildfire virtual assistance and Lumenvox’s add on for Digium’s Asterisk system one thing none could do was transcribe speech such as voicemails and this is what people want. There was a startup in the UK called Spinvox  but as anyone knows this wasn’t all it seems and when I questioned them while working on a project they clammed up and withdrew our testing account and the rest is history as they say.

So now we are many years on and Google have their second API for this service. The first API was a little flaky to say the least and came up with some amusing translations. The cloud version is much better and does a good job with most voice and also can be localised.

So what have we done. Well we have mixed together some existing code we use and created a “mini voicemail” that records your message converts it to text saves it as a voicemail and emails the resultant Text and recording to you.  In the process we did find a few “gotchas” with the API for example a pause of more than a couple of seconds will result in the translation stopping there, also a big one is that the translation takes as long as the recording is, and the API has a 60 second limit. Both of these can be overcome by limiting the record time in Asterisk to 60 seconds and using sox to remove silence of more than a second.

exten => s,n,Record(catline/${UNIQUEID}.wav,3,60,kaq)
/usr/bin/sox /var/lib/asterisk/sounds/catline/${origdir}.wav ${PATH}${origmailbox}/INBOX/${FILENAME}.flac  lowpass -2 2500 silence -l 1 0.1 1% -1 0.8 1% 

As you can see from these snippits of code above we have used variables where possible to that it can be incorporated easily with existing asterisk systems using GUIs such as Freepbx, We use the voicemail greetings that the user recorded and also use the email address thats linked with their mailbox for simplicity of management.

Now having Voicemails as text is nice but where it comes into its own is with structured mailboxes or simply put questionnaires where the caller is asked a number of predefined questions and these are recorded as one single voicemail. We already do this for some customers but they still have to have some one transcribe teh voicemail to text to input it. The quality of the Google translation means that soon they will be able to just copy the text over. Other applications are only limited by your imagination, Such as automated voice menus for Takeaways or Taxi firms.

To be Continued…HERE

Categories
Applications FreePBX Products

Zulu UC by Sangoma

Zulu UC is a unified communications desktop program that interfaces with FreePBX and PBXact. It provides call notifications, SMS, faxing capabilities and much more! Supported applications include Microsoft Outlook, Mozilla Firefox and Google Chrome.

User connections are available in 20-seat packages, so get yours today by visiting the Store tab in your FreePBX Portal!

Browser Plug-ins

Zulu UC is currently supported for Mozilla Firefox and Google Chrome on Windows machines. Make sure to install the Zulu Firefox Plugin or the Zulu Chrome Plugin before you start using Zulu UC in your browser. Support for Mac OSX is coming soon.

DataSheet can be downloaded here

Categories
FreePBX Knowledge Base

Post call emailing of Call Recordings in Freepbx

In freepbx there is a feature that is quite well hidden but actually does a very useful job.

In The “Advanced Settings” page if you enable both “Post Call Recording Script” As the name suggests this is a script that run after a recorded call has ended. We created a script called postrecord.sh and in the text field on the menu we have put as below. This emails both inbound and outbound calls.

For calls to and from an extension we can pull the email address from the voicemail.conf and send the email to that address.

Its also set to delete the wav file away after a defined number of days.

/usr/local/sbin/postrecord.sh ^{TIMESTR} ^{FROMEXTEN} ^{CALLFILENAME} ^{UNIQUEID} ^{ARG3}

The Script below will first convert the recording then email it to you or your customer.

A couple of prerequisites are required, these are sox and lame. sox is probably already installed, lame maybe not.

Installing Lame is simple for centos as below.

wget http://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz tar -zxvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
make install

The script is fairly simple as below. the main variables are passed to it but we build the directory structure on the fly and file extension is fixed as wav. you can set the file_age variable to delete the wav file messages over that many days old.

  • Be careful if cutting and pasting this scripty as wordpress may have wrapped some lines
#!/bin/bash
#This script emails the recorded call right after the call is hung up. Below are    the variables passed through asterisk
# $1 - Time String
# $2 - Source
# $3 - File
# $4 - unique id
# $5 - Destination
# $dt - Date and Time
/bin/nice /bin/sleep 3
dy=$(date '+%Y')
dm=$(date '+%m')
dd=$(date '+%d')
file_age=35

dtpath=/var/spool/asterisk/monitor/$dy/$dm/$dd/
/bin/nice /usr/local/bin/lame -b 16 -m m -q 9-resample $dtpath$3.wav  $dtpath$3.mp3
/bin/nice /bin/chown  asterisk:asterisk $dtpath$3.mp3
dt=$(date '+%m/%d/%Y %r');
id=$(mysql -uUser -pPassword -s -N -e "SELECT descr from asterisk.queues_config where extension = $5");

email=recordings@yourdomain.com

file=$dtpath$3

if [ "$id" = "" ]; then
     direction=callers 
            id=$(mysql -uUser -pPassword -s -N -e "SELECT name from asterisk.users where extension = $2");

  IN=$(/bin/grep "$2 =>" /etc/asterisk/voicemail.conf)
              echo $IN
               set -- "$IN"
               IFS=","; declare -a Array=($*)
               email=${Array[2]}

            else

            direction=customers    
            fi

echo -e "You have a new call recording to listen to\n\n
 The call date and time was: $dat \n\n 
 The call was from: $2 \n\n The call was to: $5 \n\n
 The $direction name was: $id \n\n
 And the unique call id was: $4 \n\n
 Please see the attached file \n\n" | mail -a $file.mp3 -s "New Recording at $dt" $email 

/bin/nice /usr/bin/find /var/spool/asterisk/monitor/  -type f -mtime +"$file_age" |grep wav | \
while read I; do
              /bin/rm  "$I"
done
Categories
Asterisk Support Elastix Support FreePBX Knowledge Base

Using Gmail to send Voicemail emails

We have seen more and more ISPs blocking Port 25.  This means that sending emails natively from FreePBX or any Asterisk based IPBX for things such as voicemail notification can time out or be rejected.

To get round this you can send your email notifications via Gmail.

Firstly you need a Gmail account, once you have this jot down the user and password, you will need this later.

You now need to connect to your server via ssh as you have a couple of files to edit.

Firstly you need to enter the account details in sasl_passwd

vi /etc/postfix/sasl_passwd

and add

smtp.gmail.com:587 yourmailaddress@gmail.com:password

Save it, then edit main.cf

vi  /etc/postfix/main.cf

Then add at the end:

masquerade_domains = yourdomain.com
# The servers hostname below
myhostname = Asterisk.yourdomain.com
mydomain = Asterisk.yourdomain.com
# The email account its being sent from below
myorigin = voicemail@yourdomain.com

relayhost = smtp.gmail.com:587
mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only
smtp_use_tls = yes
smtp_always_send_ehlo = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = encrypt
smtp_generic_maps = hash:/etc/postfix/generic 
smtp_tls_security_level = secure
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure_cert_match = nexthop
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

Then enter the following commands at teh command line

postmap hash:/etc/postfix/sasl_passwd
/etc/init.d/postfix restart

Finally you need to make a change to your gmail account to “Allow users to manage their access to less secure apps” which is in the security section of the Gmail ‘Domain’ account setting if its a GSuite account then make sure “Less secure app access” is set to yes in the accounts ‘security section’ if you don’t do this you will see:

535-5.7.8 Username and Password not 
accepted. Learn more at?535 5.7.8 https://support.google.com/mail/?p=BadCredentials  

or 

530-5.7.0 Authentication Required. Learn more at 530 5.7.0 h
ttps://support.google.com/mail/?p=WantAuthError

Most likely the 535 error if ‘Less secure app access’ is not enabled.

You should now be able to send email via the gmail account.

It’s worth making a couple of changes to the gmail account, firstly set and out of office sayings it’s only a sending mailbox and another to delete messages in the inbox.