Audio Files Python Module provides some functions to read and write audio files.
For each implemented audio format there is an implementation of the class audio_file_checker.
In order to create an instance of the correct implementation there is an audio_file_checker_factory in which there is a function that will return the correct implementation:
getAudioFileChecker(file: str, extension: str) -> audio_file_checker
Currently the following extensions are implemented:
- .wav
- .mp3
The class audio_file_checker contains the following methods implemented:
- isTwoChannels ( ) → returns True if the audio is Dual Mono or Stereo
- isMono ( ) → returns True if the audio is Mono
- isStereo ( ) → return True if the audio is Stereo
- isDualMono ( ) → returns True if the audio is Dual Mono
- getSr ( ) → returns the Sample Rate
- getLeftChannel ( ) → returns the left channel data (in case of a mono audio file returns the audio data)
- getRightChannel ( ) → returns the right channel data (in case of a mono audio file returns None)
The class dual_mono_converter has a constructor that takes two strings:
- input → a string with the path to a file or a folder
- output → a string with the path to the output folder
Calling the method convert ( ) will check the file (or folder) in input. Each dual mono file found will be converted to mono and written in the output folder, the other files will be simply copied, the method returns two lists: one for the converted files and one for the copied files.