How to set Speech to text API

Call Utils for Salesforce enables to use Speech to text service from Google's CLOUD SPEECH API. Unfortunately, it's paid API (with free limits for testing). Settings consist of two main steps. Get Google API access, set it to the Salesforce.

Google API access

The main goal of this part is to get JSON with new created Service account credentials. There are many ways, you can read the official documentation or try next one tutorial.

  • Visit Google Cloud Platform Console on .
  • Create new project (in our example "s2t-api-example-project") and set the Billing account (create new if you have no one).

  • Navigate Main menu (left top sandwich) > switch to API Manager > Library > search for Speech.
  • Enable Google Cloud Speech API (next to main title). Optionally you can set some limits here.
  • Enable Google Cloud Storage API. This API is newly required by Google for Speech to text API call for voice longer than 1 minute.

This longer audio records are uploaded by Call Utils for Salesforce to the GCS Bucket "callutils-s2t-temp". You can create this GCS Bucket manually or Call Utils will create it automatically in the project specified by configuration attribute "admin_s2t_gcs_project". It's recommended to create this GCS Bucket with automatic deleting files after one day. Note: All uploaded files are deleted immediately after successfully transcribed Speech to text => GCS has free limits and next billing is for GB stored in month so you will not pay anything for GCS.

  • Navigate Main menu (left top sandwich) > switch to API Manager > Credentials.
  • Create new Service account key. If you have no one, you must create a Service account first.
  • Download suggested file like JSON (you'll get something like "s2t-api-example-project-f60a210da5dd.json" file).

Salesforce Speech to text settings

The main goal of this part is set the Connected App attributes for Call Utils. At those attributes will be Google Service account settings from previous part.

  • Create new APEX class (in our example CallUtilsConnectedAppPlugin) which extends Auth.ConnectedAppPlugin.
  • Override method customAttributes(). To the String - String map set keys: "admin_s2t_gcs_project", "admin_s2t_client_email", "admin_s2t_token_uri", "admin_s2t_private_key_id", "admin_s2t_private_key_pem" with values from above downloaded JSON. See next example with other key/value settings. You can download this demo file CallUtilsConnectedAppPlugin here.
  • Attention please! Override the correct customAttributes() method for your API version. For class API level >36 it is necessary to override customAttributes(userId, connectedAppId, formulaDefinedAttributes, context). For more information, see documentation.
  • In the Salesforce setup find Connected App and Call Utils for Salesforce (for more info see Call Utils Connected App Settings).
  • Edit policies and set the property "Apex Plugin Class" (in the section Custom Connected App Handler) to new APEX class, in our example CallUtilsConnectedAppPlugin.
  • (For immediate effect) logout and login to the Call Utils for Salesforce.