我想从语音录制中滤除噪音并将其标准化。目前我正在使用Butterworth带通滤波器。
如何在我的代码中应用此功能? (我是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)
非常感谢!
答案 0 :(得分:0)
您可能首先要检查是否安装了numpy,pydub,scikits和scipy。然后,您可以使用此代码创建一个函数,并将您的音频文件作为输入。