rfft or irfft increasing wav file volume in python

痞子三分冷 提交于 2019-12-08 04:39:13

问题


I have just started writing a program to manipulate some audio in python. Before I write any filtering functions, I wanted to do a test to compare the input signal to the output signal after having the input signal go through an rfft and irfft. For some reason the output file has an incredible amount of gain in it (50db!) compared to the input file, and I can't figure out why this is happening. Here is the code:

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

rate, input = read('5and10ksm.wav')
transformed = rfft(input) 
output = irfft(transformed)
write('smaller.wav', rate, output)

Thanks!


回答1:


scipy.fftpack.irfft returns an array of floats. Convert it to the dtype of your input file before writing it as wav file: output.astype(input.dtype).



来源:https://stackoverflow.com/questions/35931169/rfft-or-irfft-increasing-wav-file-volume-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!