Raspberry Pi Caller and Answering Machine

For some purposes i thought it would be very nice to enable some telecommunication abilities on raspberry pi. For example if something does not work as it should (e.g. average load too high, temperature/humidity too high) raspberry pi can call you. Or if you just want to control something quickly via phone (e.g. starting a process, reboot or open the door) - raspberry pi can answer your calls and made it for you. Of course you can make it via SMS or web-interface, too - but for example a call often gets more attention than a sms.

So at first i’ve searched for a tts-tool. Very popluar are festival and eSpeak. For using synthesized speech later its important to cache speech as wav-files - such an option is alread included in both tools (espeak -w / text2wave). I’ve compared both tools on raspberry pi - the synthesized speech sounds similar, but espeak seems to be a bit faster with generating wav-files and is more adjustable. But at least which tool is choosen is a question of taste. Both tools are available via apt:

sudo apt-get install espeak espeak-data
sudo apt-get install festival

For making calls i’ve decided to use a sip/voip based system. I’ve found at least two possible tools which are controllable via command line: Linphone (linphonec/linphonecsh) and PJSIP. After a few tests i’ve sorted out linphone because its way to difficult to include into own applications/scripts in comparison to PJSIP. PJSIP delivers not only a command line interface - it provides a powerfull library/api (PJSUA) for using within own sip-based projects - so it was predestinated for my proposition.

For start using PJSIP/PJSUA you need to download and compile it by yourself - its not installable via apt but this is not really a problem:

sudo apt-get install subversion
svn checkout

sudo apt-get install build-essential automake autoconf libtool libasound2-dev libpulse-dev libssl-dev libsamplerate0-dev libcommoncpp2-dev libccrtp-dev libzrtpcpp-dev libdbus-1-dev libdbus-c++-dev libyaml-dev libpcre3-dev libgsm1-dev libspeex-dev libspeexdsp-dev libcelt-dev

cd trunk
./configure && make dep && make clean && make && make install

After finishing compilation (you can have a coffee or two meanwhile) you can test a bit around with pjsystest or pjsua which are available in /pjsip-apps/bin. With the actual raspbian-os i’ve discovered some sound-problems with making normal calls to another phone (echo/jitter) which seems to be alsa/pulse-based.

For my proposition i’ve created two tools: sipcall and sipserv. With sipcall you can easily make an automated call to a specified number with a text to speech. Its easy usable via bash-script for example to check a system or sensor state and place a call if a critical threshold is reached. Sipserv however acts more like a service - you can make a call to it and query informations or execute commands via phone (your sip-provider needs to support inbound dtmf - i’m using sipgate, which works fine). You can download them from my github-repository. For compiling both tools you need the pkg-config-package:

sudo apt-get install pkg-config

I’ve also created a simple bash-script for checking actual load and placing a call if load is too high. For sipserv there is a sample configuration and a bash-script for starting/stopping the service available. All files are well documented to understand how it works - general infos are also available in the readme-file.

Both tools work so far but currently they are in alpha state and more “proof of concept" than final. Feel free to play a bit around, test or extend them. Please let me know if you have improvements, especially for the current sound problems.

  1. naoiwata reblogged this from binerry
  2. designthinkering reblogged this from binerry
  3. binerry posted this
Blog comments powered by Disqus