Using Speech in Your IoT Projects


After seeing Michael Li’s awesome Amazon Alexa IoT demo at the last IoT developers meetup, I decided to look into ways to incorporate speech into our IoT projects even if we don’t have a spare Amazon Dot to use in a project.

The Inspiration

Michael Li put together a tutorial and two videos for his IoT project. Thanks Michael.

He’s using the cloud-driven GPIO features of the Renesas IoT Sandbox Data Intelligence binary for Diagnostics Intelligence.

Alternative to Amazon

Although many people in this community are already working with Amazon for IoT data, I took a look at the IBM Cloud because I heard good things about Watson as a result of some consulting I’m doing for IBM. Watson has a good set of text to speech and speech to text APIs. I was able to get things running in under 30 minutes with a free trial account.

Let’s check out the IBM Watson text to speech API.

Introduction to Watson APIs

IMPORTANT FOR Manhattan College Meetup Partcipants

If you are in the Manhattan College Meetup, you do not need to create a Watson Account.

We have created a temporary account for you and the API key is in the file

If you are not in the meetup, you will need to create a free Watson API account.
To use Watson APIs, sign up for a free account. Go to the main IBM Cloud Catalog. At the bottom left, there is a section for Platform. Select Watson. To the right, select Text to Speech.

When I first went to Watson, I got this message.

I set up my space.

Under Dashboard -> Services

Access Watson API Service Credentials

   curl -X POST -u {username}:{password} \
    --header "Content-Type: application/json" \
    --header "Accept: audio/wav" \
    --data "{\"text\":\"welcome to the IoT Community\"}" \
    --output hello_world.wav \

I’m using VS Code to save my tests as a bash script.

Meetup Participants, Continue Here

Watson API Bash Test With Data From File

This is the modified bash script.


curl -X POST -u 00f86533-f3c0-your-username:password \
--header "Content-Type: application/json" \
--header "Accept: audio/wav" \
--data "{\"text\":$DATA}" \
--output hello_world.wav \

Example on GitHub

Getting IoT Data Into Watson APIs

Michael’s great tutorial used Renesas IoT Sandbox Data Intelligence to process IoT data from the S5D9 IoT Fast Prototyping Kit. I’ll show a different approach of using the Renesas IoT Sandbox Data Monitoring API to pull IoT data down. The Data Monitoring binary is the default binary everyone was using in the last meetup, shown in the picture below. It’s the first binary that boots when you open up the box and board for the very first time.

Once the data is into your application, you can trigger an alert based on data anomalies and then send a text alert to the IBM Watson API for processing into a voice alert.

Your S5D9 IoT Fast Prototyping Kit board should look like the picture below.

Make sure the Ethernet lights are flashing. Verify you are receiving IoT sensor data on your dashboard.

With your S5D9 plugged into both USB and Ethernet, modify this URL and put it into a browser.

You can also use the IoT Sandbox API console.

Get IoT JSON Data from your S5D9.

With curl

Example on GitHub

Create text data to send to Watson.

import json

with open('iot.json') as json_data:
    d = json.load(json_data)
    sensor_data = (d['with'][0]['content']['sensors'])
    watson_data = "\"The current temperature in Fahrenheit is " + \
        str(sensor_data['TemperatureF']) + ". "
    watson_data += "Sound level is " + str(sensor_data['SoundLevel']) + ".\""
    # print(watson_data)
    watson_file = open('watson.dat', 'w')

Example on GitHub

Verify Watson data was saved to file.

$ cat watson.dat 
"The current temperature in Fahrenheit is 88. Sound level is 5."

Use a modified shell script for testing.


curl -X POST -u 00f86533-f3c0-46e6-b731-username:7r4password \
--header "Content-Type: application/json" \
--header "Accept: audio/wav" \
--data "{\"text\":$DATA}" \
--output iot-data.wav \

Example on GitHub

Video Showing Process

Embedded with sample sound

GitHub Repository of All Code Samples


By combining IBM Watson APIs with APIs from the Renesas IoT Sandbox Data Monitoring, you can quickly build an IoT system with voice alerts. The Renesas IoT Sandbox is designed to work with third-party APIs to enable you to bring your IoT project to market in less time and with lower development costs.

Next Tutorial

In the next tutorial I’ll cover how to tie the concepts together with a simple mobile app that uses the IBM Watson API to provide voice alerts on your mobile phone for your IoT data spread out around the world.

Part 2 - How To Create a Mobile App GUI

How To: IBM Watson API with Renesas IoT Sandbox Data Monitoring
Meetup - New York - Nov 29 - Hands On Training with Renesas S5D9 IoT Fast Prototyping Kit

Hi Craig,

Thank you for your kind words on my demo! Your new IBM Watson tutorial is so cooooool. I want to try it. Thank you for your awesome post.



Thanks for the feedback. :slight_smile:

The main goal is to show that Data Monitoring does have an API that can be used to pull the IoT data down to your own system. Once you have the sensor data, you can do anything you want with it. I chose to connect it to a well-known API from IBM, a big technology company to illustrate that an independent consultant or individual within an organization could tie together IoT data with any type of API and offer a “production” solution quickly.

Right now, the glue between the two APIs is very basic, but I think people can see the potential of tying IoT data to another system. It’s just to spark the imagination right now.

It’s also fun to build these things and talk about it with interesting people like you. :sunglasses:


Yes. IBM is always a great company. I totally agreed with you. It is very exciting!!