Ham radio (Amateur radio) allows people to communicate using legal frequency ranges by personal devices that you can easily buy from the market. They are mostly used by amateur radio enthusiasts, and they can be used to communicate freely like a cell phone. Their transmit power varies depending on hardware, limited by legal limitations. They can be used from miles away, or they can be deployed in a single building. There are even amateur radio satellites in space which are used for weather forecasting, downloading space photos, or very long-range communications.

Software-defined radio (SDR) is a radio communication system where components are instead implemented utilizing the software. Compared to traditional hardware-based radios, they allow quick prototyping and new possibilities. Next-generation radio such as LTE & 5G is already using SDR with Software Defined Networking (SDN).

In the market, you can buy a hobby SDR USB dongle for a reasonable price. You can use these dongles to listen to FM and DAB (Digital Audio Broadcasting) stations, get weather reports from satellites, watch HDTV or you can use them as a ham radio sink.

In this blog post, we will show you how you can receive a radio signal from ham radio, using a USB RTL-SDR Dongle and convert it to an Opsgenie Alert using AWS Lambda and AWS Transcribe.

ham2mon

ham2mon is an open-source SDR scanner tool written in Python. It can use the RTL-SDR USB Dongle antenna to receive and record voice communications. When a signal strength larger than a threshold is received, ham2mon detects it as a communication and can save it as a .wav file. We have extended ham2mon to upload this .wav file of recorded detected communications to AWS S3 so that we can trigger an AWS Lambda function that will use AWS Transcribe API to convert audio to the uploaded file to text.

Transforming voice to data & alerts

To make an interesting use case, we have imagined this scenario: When we detect a phrase in predefined words, like “Help”, “Execute Order 66”, “North outpost is compromised”, “Eggs are boiled”, we want to create an alert in Opsgenie. Opsgenie can send notifications to users via various ways such as push notifications and calls.

Amazon Transcribe uses advanced machine learning methodologies, to convert an audio stream to a text. As mentioned before, ham2mon uploads to .wav files to S3 and a Lambda is triggered from S3 Events. Lambda calls Transcribe API and depending on the result, Lambda creates an Opsgenie Alert through API.

Uploading radio communication to AWS S3 flow

Due to the nature of radio communications & hardware, there can be noise that can render some recordings unusable. Therefore, we filter out files less than 10KB, because they probably do not contain intelligible words, or they mostly consist of noise. We also filter out communications for less than 3 seconds.

Amazon Transcribe also has a nice feature that you can define your vocabulary to help to recognize familiar audio. It can be useful if you expect certain keywords in your recordings. In our case, we reduced the effect of a low-level noise and increased the success rate. To simplify our experiment, we have defined three words in vocabulary: blue, team, red. If the recording consists “blue team”, we will assign the alert to blue-team and similarly for the “red team”. After the vocabulary status is ready, they can be referred to in Transcribe API calls.

S3 event listeners can be configured to trigger AWS Lambda functions. So whenever an audio file is uploaded to an S3 bucket, our lambda function is called. This Lambda function will get the file path from the request and create a TranscriptionJob in AWS Transcribe API with the settings shown in the code below. Since ham2mon records audio using WAV format, we selected the correct settings for our audio, i.e 8Khz sample rate. The flow can be seen in the diagram below.

AWS Transcribe job flow

Transcribe Parameters — https://gist.github.com/ffahri/9cf4b11b6201ca3cc2387ee6574ded54

In the end, the Lambda function should look like the following:

Since the Transcription works asynchronously, we cannot wait for the results in the same Lambda function. After a Transcription job completes, its output is written to another file in S3, where we attach another function to consume its contents and decide how to create an alert in Opsgenie.

We create an integration in Opsgenie to get an API Key and provide it to the second Lambda function as an environment variable. The second flow can be seen from the diagram below:

Alert generation flow based on Amazon Transcribe results

We did our experiment in a single room, but it can be easily extended to miles if you have the proper hardware. We shouted “Red team, please commence, our base is under attack” to our ham radio, it got transferred over the air using radio waves in UHF-439.300 MHz. The SDR dongle connected to an Ubuntu Linux machine receives and modified ham2mon software decodes it. We have made some tweaks to settings of ham2mon to improve recognition performance. After decoding is complete and a conversation is detected, the .wav file is uploaded, and by our Lambda functions and AWS Transcribe, an alert assigned to the Red team is created with the body of the text. If you do not speak clearly, the text can be corrupted but it works most of the time. Here is an individual alert received in our system!

Opsgenie alert

You can extend these simple ideas to many use cases. Capturing radio waves might allow you to create an Opsgenie Alert from a device or a location that is not connected to the internet. You can create an alert from a source miles away. While employing radio waves to create alerts might seem unusual, you can think of interesting applications. SDR dongles are getting popular and cheaper every day.

Take a look the following repositories if you want to see the code:

Listen audio bucket Lambda: https://github.com/ffahri/s3-event-listener

Alert Lambda: https://github.com/ffahri/transcribe-results

Forked ham2mon: https://github.com/ffahri/ham2mon