Speech to text using Google Cloud (voicemails to text)
This guide will shows how to use Google Cloud to add speech-to-text voicemail transcription to voicemail notification email messages.
Requirement: You need to be able to send emails from your PBX, follow this guide if this is not working on your PBX
Â
The first thing you need to do is to have a Google Cloud account, you can request a free account for testing here
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 |
Â
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'` |
You will need some extra packages, just type this on your CLI:
Type these commands:
Â
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.
Â
Go back to the CLI and do this:
Â
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
Â
NOTE
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.
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:
Â