0
내가 wav 파일에 FFT를 사용하는 방법에 대한 this question and answer를보고 이런 식으로 구현하려고 :FFT wav 파일이 필요합니까?
import matplotlib.pyplot as plt
from scipy.io import wavfile # get the api
from scipy.fftpack import fft
from pylab import *
import sys
def f(filename):
fs, data = wavfile.read(filename) # load the data
a = data.T[0] # this is a two channel soundtrack, I get the first track
b=[(ele/2**8.)*2-1 for ele in a] # this is 8-bit track, b is now normalized on [-1,1)
c = fft(b) # create a list of complex number
d = len(c)/2 # you only need half of the fft list
plt.plot(abs(c[:(d-1)]),'r')
savefig(filename+'.png',bbox_inches='tight')
files = sys.argv[1:]
for ele in files:
f(ele)
quit()
을하지만, 내가 전화 할 때마다 :
:Traceback (most recent call last): File "fft.py", line 18, in <module> f(ele) File "fft.py", line 10, in f b=[(ele/2**8.)*2-1 for ele in a] # this is 8-bit track, b is now normalized on [-1,1) TypeError: 'numpy.int16' object is not iterable
$ python fft.py 0.0/4515-11057-0058.flac.wav-16000.wav
나는 오류
인수 목록에있는 각 파일의 빈도 분포를 생성하는 스크립트를 어떻게 만들 수 있습니까?
''''는 단지 정수입니다. 트랙이 2 채널인지 확인 하시겠습니까? – alexblae
@alexblae 그들은 모두 싱글 채널입니다. – theonlygusti