Created and recorded by Yiming Cai, December 2021.
Music: "Call of the Void" by Justin Miles, https://lmms.io/lsp/?action=show&file... License: Creative Commons (by)
Examples of voice-controlled AIs
Introduce to speech recognition library
Convert audio file to text
Convert voice from mic to text
Summary & mention next topic: text to audio
Voice-controlled AI such as Siri and Alexa are becoming a part of our life. The basic technique for them to understand your voice is converting your voice into text. Today, I will teach you how to convert audio to text by using the python library: speech recognition
SpeechRecognition is one of the most popular library for converting voice to text. SpeechRecognition does not need to build a script to access the microphone and process audio files from scratch. It only takes a few minutes to automatically complete audio input, retrieval and operation. Therefore, the ease of use is very high.
SpeechRecognition has 7 different recognizers, and today, we are going to use google web speech API in this video.
Note that the Google API requires an Internet connection. Please make sure the internet is well connected when using this API.
The first step will be to install the library.
pip install SpeechRecognition
After installing this package, there are two essential package need to be installed if you need to use microphone for audio input.
brew install portaudio
pip install pyaudio
Pyaudio is relying on the port audio, so make sure the portaudio is installed before the pyaudio installation.
Code for converting .wav to text.
Code for converting mic audio to text.
So in this video, we introduced how to use speech recognition to convert the audio file to text. Next time, we will discuss how to teach the computer to understand your voice commands, and answer back with its voices. Hope this video is helpful