-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio-file-converter.py
More file actions
32 lines (24 loc) · 1.02 KB
/
Copy pathaudio-file-converter.py
File metadata and controls
32 lines (24 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from pydub import AudioSegment
# Define the folder path containing the audio files
folder_path = 'path/to/your/folder'
output_folder = 'path/to/output/folder'
# Ensure the output folder exists
os.makedirs(output_folder, exist_ok=True)
# Iterate over each file in the folder
for filename in os.listdir(folder_path):
# Construct full file path
file_path = os.path.join(folder_path, filename)
# Check if the file is an .aac or .m4a file
if file_path.endswith(('.aac', '.m4a')):
try:
# Load the audio file using pydub
audio = AudioSegment.from_file(file_path)
# Construct the output file path
output_file_path = os.path.join(output_folder, os.path.splitext(filename)[0] + '.wav')
# Export the audio file as .wav
audio.export(output_file_path, format='wav')
print(f"Converted: {file_path} to {output_file_path}")
except Exception as e:
pass
print("Processing complete.")