This guide will shows how to use Google Cloud to add speech-to-text voicemail transcription to voicemail notification email messages.
1) The first thing you need to do is to have a Google Cloud account, you can request a free account for testing here
2) Now we need to install Google Cloud SDK package, just go to your CLI and type this as root: (just copy&paste and hit Enter)
We add the repository first
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM [google-cloud-sdk] name=Google Cloud SDK baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=0 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOM
yum install google-cloud-sdk
3) We need to download the bash script which will be the one for sending the emails and converting audio files to text. (just copy this file to your PBX on /usr/sbin)
If you need to change the language, just change this line: (change the en-US to your language)
RESULT=`gcloud ml speech recognize stream.part3.flac --language-code='en-US'`
4) You will need some extra packages, just type this on your CLI:
yum install -y jq sox flac dosunix
5) Type these commands:
cd /usr/sbin/ chown asterisk:asterisk sendmail-gcloud chmod 744 sendmail-gcloud chmod 777 /usr/bin/dos2unix
6) Now it's time to go to your Google Cloud Platform and create a new project or use the one you already have.
Inside our project, we search for Cloud Speech to API and we enable it.
Finally, if you go to your projects, you will see your project ID, keep it cause we will need that in a few.
7) Go back to the CLI and do this:
gcloud auth login
You will be asked to copy a URL and paste on your browser, you have to select your Google Cloud account and then accept the Google Cloud SDK permission.
Finally, you should see a code which is your verification code, you need to paste that on your CLI
If the above command gives you the warning 'You are authorizing gcloud CLI without access to a web browser...' without the direct URL to paste on the browser, add the --no-launch-browser so it looks like this: gcloud auth login --no-launch-browser
The last thing we need from the CLI is to tell gcloud which is our project.
[[email protected] sbin]$ gcloud config set project freepbx-285412 (change this with your project id) Updated property [core/project].
8) We are almost done, go to your FreePBX web interface
Settings > Voicemail Admin > Settings > Email Config
Change Mail Command to: /usr/sbin/sendmail-gcloud
Submit and apply changes
Ok, we just need to make a test now and see how it goes, if everything went ok you should see something like this: