First, we'll record the voice which needs to be transcribed in FLAC format. Then, we'll use a Python program to invoke the Speech API and get the transcribed response:
- Navigate to the Chapter05/speech-api folder.
- If you are on a Linux-based operating system, install the SoX package:
$ sudo apt-get install sox
Or for CentOS:
$ sudo yum install sox
- Next, using the rec command, we can record the message which needs to be transcribed:
$ rec -c 1 -r 16000 record.flac trim 0 3
The preceding command will record an audio message for 3 seconds with a sample rate of 16000 Hz.
- To execute the program in an isolated environment, create a virtualenv and install the dependent packages:
$ virtualenv ENV$ source ENV/bin/activate$ pip ...