Okay, time to write some code that does audio recording for us.
Download the file
RecordingAudio.py
and review the code. You will notice that the only important task is to set up a proper pipeline for audio recording. Content-wise, the other code is very much similar to what we learned earlier in the chapter. It will have some minor differences such as method names and print statements. In this section we will discuss only the important methods in theclass AudioRecorder
.Write the constructor.
def __init__(self): self.is_playing = False self.num_buffers = -1 self.error_message = "" self.processArgs() self.constructPipeline() self.connectSignals()
This is similar to the
AudioPlayer.__init__()
except that we have added a call toprocessArgs()
and initialized the error reporting variableself.error_message
and the variable that indicates the total duration of the recording.Build the GStreamer pipeline by writing
constructPipeline
method.1 def...