IoT Bytes

Bits and Bytes of IoT

Record Audio from Phone Line with Raspberry Pi

Pradeep Singh | 25th Jun 2018


In this article, I am going to explain the process of recording a landline phone(POTS) call using a USRobotics USR5637 USB Dial-up Modem and Raspberry Pi. I would use the modem AT commands and a python script to automate the recording process.

1. Hardware Setup:

The following picture shows the setup that I would be using for this article. Here I have a Raspberry Pi connected to a USRobotics USR5637 USB Modem –


2. Compression Methods and Sampling Rates Supported by USRobotics Modem:

Before you start recording the audio from the phone line, you need to pick one of the following compression method and sampling rates as shown in the following table. You would use these values with the VSM AT Command (AT+VSM=cml,vsr). The “cml” parameter identifies the compression method and the “vsr” parameter identifies the sampling rate.


3. AT Command Sequence to Record the Audio:

As per the USRobotics 56K USB Modem: Voice Commands User Guide, you may follow the AT command sequence examples to record the audio file from the analog modem. These commands would use the terms DTE and DCE in the command description. The following image would help you to identify the DTE and DCE devices in the hardware setup –


The following AT command sequence configures some default params on the Modem goes off-hook when it (modem) receives an incoming call –


The following command sequence would play to beep to the caller (to notify him that the recording has been started) and start sending the audio data to the Raspberry Pi –


After recording the audio the caller may drop the call or stop speaking. The modem will pass “silence” or “end of audio transmission” message to the Raspberry Pi. At this stage, Raspberry Pi should pass “ATH” command to hang-up the call as shown in the following AT command sequence –


4. Download Python Script Sample:

You can download the sample Python script with implementation on these AT Commands to record an audio message from my Github Repository, using the following command –

git clone

Following terminal output shows the git clone output on raspberry pi –

pi@raspberrypi:~ $ git clone
Cloning into 'record_audio_from_phone_line'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
pi@raspberrypi:~ $

On successful code download, you should see “record_audio_from_phone_line” directory under your present working directory. CD into the “record_audio_from_phone_line directory and make sure you have “” file under it, as shown in the following terminal output – 

pi@raspberrypi:~ $ cd record_audio_from_phone_line
pi@raspberrypi:~/record_audio_from_phone_line $ ls
pi@raspberrypi:~/record_audio_from_phone_line $

5. Execute Python Script to Record the Audio:

To run the python script, execute the following command (make sure you are inside record_audio_from_phone_line directory) –


Now you can call your landline number and record the audio message after the beep tone.

Following screenshot shows the terminal output of the python script. Here script is monitoring the phone line for incoming calls –


Modem answers the call when it receives an incoming call, plays a beep tone and start recording the audio message. The following screenshot shows the Raspberry Pi terminal output while recording the audio message –


6. Audio File Name Format:

The audio files will be saved with the following naming convention under the same directory as the python script –


The following terminal output shows a recorded .wav file –

pi@raspberrypi:~/record_audio_from_phone_line $ ls
pi@raspberrypi:~/record_audio_from_phone_line $

Related Articles:

USB Analog Modem with Raspberry Pi

Play Audio File on Phone Line with Raspberry Pi

Incoming Call Details Logger with Raspberry Pi

Python Script to Reset USB Modem COM Port on Raspberry Pi

Python Script to Autodetect Modem COM Port on Raspberry Pi


Wikipedia – Voice modem command set

USRobotics 56K USB Modem Voice Commands

USRobotics 56K USB Modem – Data and General Commands

Voice +V Commands – Developer’s Guide

Blog Home Page:

Let’s Decipher IoT…

One thought on “Record Audio from Phone Line with Raspberry Pi

  1. Hi,
    Congratulations, yours posts are very usefull. Im trying to use yours instructions but using the Conexant USB CX93010 in the PABX(its very cheap) . I adapted the python and something run others no. But my big problem is how to detect when the remote phone is off hook. Because, when its occur I play a sound file.
    The USRobotics and Conexant are very similar. I send:
    ATD26 //my telephone extension

    After the ATD the OK can come any time, atfer 3 rings or 10 or never
    Can you help me?
    PS.: Sorry for my poor english.
    Fernando Maesso


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: