Generating audio files from samples transmitted over the serial
If the previous recipe taught us the method for recording audio using a microcontroller, our next objective is to create audio files we can reproduce on our computer.
In this recipe, we will develop a Python script locally to generate audio files in .wav
format from the audio samples transmitted over the serial.
Getting ready
In this recipe, we will develop a Python script locally to create audio files from the data transmitted over the serial. To facilitate this task, we will need two main Python libraries:
- pySerial, which allows us to read the data transmitted serially
- soundfile (https://pysoundfile.readthedocs.io/), which enables us to read or write audio files
The soundfile library can be installed with the following pip
command:
$ pip install soundfile
Using the write()
method provided by this library, we can generate audio files in various formats from NumPy...