0

I want to filter out noises from a voicerecording and normalize it. Currently I am struggeling with a Butterworth bandpass filter.

How do I apply this in my code? (I'm new to Python)

from numpy import nditer
from pydub.audio_segment import AudioSegment
from scikits.audiolab import wavread

from scipy import signal

# Stereo to mono
stereo_sound = AudioSegment.from_wav('voice.wav')
mono_sound = stereo_sound.set_channels(1)
mono_sound.export('voice_mono.wav', format='wav')

podcast = wavread('voice.wav')

for frame in podcast:
    print(frame)

print("\n")
print("\n")


# Read mono file
podcast = wavread('voice_mono.wav')
frames = podcast[0]
max_iter = 2000
i = 0
for frame in nditer(frames):
    i += 1
    if i < max_iter:
        print(frame)


# Apply Butterworth filter

# Do Butterworth filter and save as new wav
b, a = signal.butter(4, 100, 'bandpass', analog=True)

Thanks alot!

Ashura
  • 86
  • 10

1 Answers1

-1

You may first want to check that you have numpy, pydub, scikits and scipy installed. You could then create a function with this code and put your audio file as the input.

LeoQLF
  • 63
  • 1
  • 2
  • 6