-
-
Save SamuelAlgheriniAI/0c3abed928485e64fc4b227bb6516606 to your computer and use it in GitHub Desktop.
Pre-processing the file. Conversion to wav and moving to conversion folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pre-processing function | |
def preprocessing(path_base, path_converted_audio): | |
for file in os.listdir(path_base): | |
filename, file_extension = os.path.splitext(file) | |
print("\nFile name: " + file) | |
if file_extension == ".wav": | |
file_to_process = file | |
shutil.copy(path_base + file, path_converted_audio + file) | |
elif file_extension in extension_to_convert: | |
subprocess.call(['ffmpeg', '-i', path_base + file, | |
path_base + filename + ".wav"]) | |
shutil.move(path_base + filename + ".wav", path_converted_audio + filename + ".wav") | |
print(file + " is converted into " + filename +".wav") | |
else: | |
print("ERROR: Unsupported file type - "+ file + " was not converted. Modify the pre-processing stage to convert *" + file_extension + " files.") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment