I am trying to load an mp3 file using pydub's AudioSegment method with below code.
from pydub import AudioSegment from pydub.playback import play from noisereduce import reduce_noise import numpy as np from io import BytesIO # Open the audio file using a file object with open("wind__artic__cold-6195.mp3", "rb") as f: audio_data = f.read() # Save the audio data to a temporary WAV file with open("temp_audio.wav", "wb") as temp_audio_file: temp_audio_file.write(audio_data) # Load the temporary WAV file with AudioSegment audio = AudioSegment.from_wav("temp_audio.wav") # Apply noise reduction audio_samples = np.array(audio.get_array_of_samples()) reduced_audio_data = reduce_noise(y=audio_samples, sr=audio.frame_rate, n_std_thresh=2, prop_decrease=1.0, verbose=False) reduced_audio = AudioSegment(reduced_audio_data.tobytes(), frame_rate=audio.frame_rate, sample_width=reduced_audio_data.dtype.itemsize, channels=1) # Smooth the audio smoothed_audio = reduced_audio.low_pass_filter(3000) # Adjust the cutoff frequency as needed # Save the processed audio smoothed_audio.export("output_audio.wav", format="wav") # Clean up the temporary WAV file import os os.remove("temp_audio.wav")
But continuously I am getting error as :
FileNotFoundError: [WinError 2] The system cannot find the file specified.
Do anyone have resolved this kind of issue?