Let's write a simple audio file converter. This utility will batch process input audio files and save them in a user-specified file format. To get started, download the file AudioConverter.py from the Packt website. This file can be run from the command line as:
python AudioConverter.py [options]
Where, the [options]
are as follows:
--input_dir
: The directory from which to read the input audio file(s) to be converted.--input_format
: The audio format of the input files. The format should be in a supported list of formats. The supported formats are "mp3", "ogg", and "wav". If no format is specified, it will use the default format as ".wav".--output_dir
: The output directory where the converted files will be saved. If no output directory is specified, it will create a folderOUTPUT_AUDIOS
within the input directory.--output_format
: The audio format of the output file. Supported output formats are "wav" and "mp3".Let's write this code now.
Start by...