We are going to try out the Azure Cognitive services from Microsoft and build an example of the Speech to text on a IoT device like raspberry. We will be using youtube videos for our source of speech which would be the input, we will consume the speech data via Mic connected to raspberry and display the converted text in real time over a LCD screen.
- RaspberryPi : We will be using the 4GB variant.
- Microphone Usb plug n play : Any USB plug and play device can do the job.
- Lcd Screen : We are using this for rich text quality and setting up most of our stuff. You can use any other compatible displays.
- Pair of Keyboard and Mouse : A basic keyboard mouse for using as input devices on raspberry.
Raspberry Pi can run a fully Desktop OS which can be loaded onto an MicroSD card.
Now on your desktop computer Download and Install Raspberry Pi Imager
First we select storage device, connect the Microsd card to card reader connect to computer.
Now you will be seeing the connected device as storage device, select it.
We will be using Ubuntu Desktop 64 bit, so first select the other available OS. (Although Raspbian does come in a 64bit version but Ubuntu seem to have better support for the architecture and available software)
From there we select the ubuntu 22 64 bit version.
Now after clicking write you see a similar loading bar. let it complete the process.
Ok now let's safely eject the sd card and start setting everything over our raspberry pi.
First we insert the sd card into the raspberry pi 4 which can be found underneath the board.
Connect the display via USB (To, Power/Capacitive Touch Input) and HDMI ports.
- HDMI (Display) to Micro-HDMI (RaspberryPi).
- Micro-USB (Display) to USB (RaspberryPi)
Connecting USB Mic to an usb port.
Connect the keyboard and mouse, i have a wireless plug and play usb dongle.
Connect the power USB type C.
Ok looking over everything how they should look like.
Ok first power up the device and set up the initial setup, this part would pretty much self-explanatory, but it would have following steps.
- You will be presented with initial option to connect to internet over wifi (or you can connect with Ethernet cable).
- Select the keyboard layout according and also the timezone.
- This bit is important you need make a user account.
note instead of Require my password to log in select the login automatically.
Open terminal on desktop.
let's make a directory using terminal.
mkdir work
cd work
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel Current
Once the files are installed we set the environment variables.
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.bashrc
source ~/.bashrc
Check and verify the installation
dotnet --version
sudo apt-get update
sudo apt-get install build-essential libssl-dev libasound2 wget
There is a high chance you will be having trouble in installing libssl1.0.0 as its not available for ubuntu 22. But its one of the core required dependencies. What we will do is manually install it.
wget http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1n-0+deb11u1_arm64.deb
and we simply install from the file
sudo apt install -f ./libssl1.1_1.1.1n-0+deb11u1_arm64.deb
https://azure.microsoft.com/en-us/free/
You can sign up for a free trial account with $200 azure credit for 30 days.o
once presented with the dashboard. Select more service (assuming you will already have trial subscription setup)
now select the cognitive services.
Now create a new speech service
What you will need from here once setup speech service. are the keys and the region. copy the key anyone would do and copy the location region.
Download install git
sudo apt install git
lets go back in the folder we created
cd work
clone this repository, go to the folder with the code
git clone https://github.com/m-mohsin-ali/closed-captioning-azure-speech-ai
cd closed-captioning-azure-speech-ai/code/AzureSpeechCC
Now lets put your keys in the code
nano Program.cs
class Program
{
static string YourSubscriptionKey = "Enter your Key Here";
static string YourServiceRegion = "Enter your Region here";
...
Now press crtl+x and save/overwrite.
let's add the Azure Speech Sdk lib/package to the code directory
dotnet add package Microsoft.CognitiveServices.Speech
Now lets run and see the magic
dotnet build
dotnet run