Fady Anwar Explains How to Use Raspberry Pi, Azure Speech Cognitive Service and nodejs to Tweet with Voice Recognition
Here is something fun to do this weekend. How about tweeting using voice recognition? We are going to do this using Raspberry Pi, Azure Speech Cognitive Service and nodejs.
First you will need to setup your Raspberry then create a Speech cognitive service on Azure. You will also need to create a developer account and an app on twitter to get security keys and tokens.
In this 'how to' article we are going to use this twitter npm package. Also we will use node-audiorecorder to record voice messages and send it to the Speech API. In order to install these you will need to run the following commands on your terminal.
When ready test your access to twitter using the below code which will connect to twitter service and query my twitter account for latest tweet text. You will need to replace the below placeholders with values from your Twitter developer account.
Now moving to recording and speech part. Let’s make sure that you can record wav files by running this nodejs script. The script will record sound for 5 seconds then stop.
You should get a file in the same directory called tweet.wav with your recording. You can play it from your shell terminal by typing this play tweet.wav command.
If you can hear yourself then so far so good. Now let’s do the fun part, create a new file called voicetweet.js on your Raspberry Pi and paste into it the below script and fill in the place holders with the speech subscription service as well as twitter consumer key, token and their secrets.
When all in place, type the command node voicetweet.js on your Raspberry Pi terminal.
You should see confirmation messages with the json values of the results coming back from both Azure and Twitter. This mean that you just had made your first tweet mentioning me using voice AI recognition on a Raspberry Pi.
Congratulations!
Fady Anwar has more than fifteen years experience in software engineering, consultation, system design and architecture, IT project management and service management with multinational and multi industry exposure such as telecom, real estate, readymix, investment, health, insurance and education.
A native of Egypt, Fady currently lives in Dublin where he works at TEKenable as a Solution Architect, specializing mainly in Microsoft Dynamics 365 and Power Platform business solutions.
Nevertheless, he is always exploring new technical ventures such as IoT, AI and cloud services to augment his knowledge on how to best extract value from technologies to help businesses thrive.
Visit: www.fadyanwar.com / @fadyanwar
Want to contribute? Check out our Guest Writers section
Get Instant Irish Tech News Updates on our Social Channels....
![]() |
![]() |
![]() |