Getting Started
To get started, you’ll need to install a few prerequisites:Helper Functions
Now we’ll need to define a few helper functions before we set up our full workflow. The first one,load_audio will load any audio file, regardless of format, and return each channel as a NumPy array.
hash_audio_data hashes each channel to return a SHA-256 hash.
compare_audio_channels lets us know via a flag if the audio channels are the same, with 1 meaning that they are the same, and 0 meaning they’re not.
convert_to_mono_if_duplicate that removes one of the audio channels and creates a new mono file that we can submit to AssemblyAI, returning the path to it. If the file contains different content on each channel, however, this function will instead return the original file path.