简体   繁体   中英

Python NumPy Convert FFT To File

I was wondering if it's possible to get the frequencies present in a file with NumPy, and then alter those frequencies and create a new WAV file from them? I would like to do some filtering on a file, but I have yet to see a way to read a WAV file into NumPy, filter it, and then output the filtered version . If anyone could help, that would be great.

SciPy provides functions for doing FFTs on NumPy arrays, and also provides functions for reading and writing them to WAV files. eg

from scipy.io.wavfile import read, write
from scipy.fftpack import rfft, irfft
import np as numpy

rate, input = read('input.wav')

transformed = rfft(input) 

filtered = function_that_does_the_filtering(transformed)
output = irfft(filtered)

write('output.wav', rate, output)

( input , transformed and output are all numpy arrays)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM