-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmp3ToWav.py
More file actions
23 lines (19 loc) · 917 Bytes
/
mp3ToWav.py
File metadata and controls
23 lines (19 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pydub import AudioSegment
import os
class Mp3ToWavConverter:
def __init__(self, input_dir="./Downloads", output_dir="./Downloads"):
self.input_dir = input_dir
self.output_dir = output_dir
os.makedirs(self.output_dir, exist_ok=True)
def convert_all(self):
for filename in os.listdir(self.input_dir):
if filename.lower().endswith(".mp3"):
mp3_path = os.path.join(self.input_dir, filename)
wav_filename = os.path.splitext(filename)[0] + ".wav"
wav_path = os.path.join(self.output_dir, wav_filename)
audio = AudioSegment.from_mp3(mp3_path)
audio.export(wav_path, format="wav")
print(f"Converted: {filename} -> {wav_path}")
# Example usage:
# converter = Mp3ToWavConverter(input_dir="./Downloads", output_dir="./Downloads")
# converter.convert_all()