In this example project, we will convert SMS to audio using the sipgate.io node library library and gTTS.
sipgate.io is a collection of APIs, which enables sipgate's customers to build flexible integrations matching their individual needs. Among other things, it provides interfaces for sending and receiving text messages or faxes, monitoring the call history, as well as initiating and manipulating calls. In this tutorial, we will use sipgate.io's history API to read incoming SMS text messages from your sipgate account.
The script in this repository pulls all SMS in a specified date range from your history and converts them to single mp3 files.
To achieve this we use our sipgate.io node-library in combination with the google text-to-speech package.
Prerequisite: You need npm
and Node.js installed on your machine.
To be able to launch this example, navigate to a directory where you want the example service to be stored. In a terminal, you can clone this repository from GitHub and install all required dependencies using npm install
.
git clone https://github.com/sipgate-io/io-labs-sms-to-speech.git
cd io-labs-sms-to-speech
npm install
Make sure to set the credentials of your sipgate account (token and token ID with scope: history
, see Personal Access Token documentation on sipgate.io) either in a .env
file or by providing them as temporary environment variables at program execution:
SIPGATE_TOKEN=<token> \
SIPGATE_TOKEN_ID=<tokenId> \
npm start
You should now be able to convert your SMS.
In this example, we used gTTS to convert our SMS, however you can choose and use any package you like. A short, non-exhaustive list of open source options: