简体   繁体   English

rfft或irfft增加python中的wav文件量

[英]rfft or irfft increasing wav file volume in python

I have just started writing a program to manipulate some audio in python. 我刚刚开始编写程序来处理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. 在编写任何滤波功能之前,我想做一个测试,以在输入信号经过rfft和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. 由于某种原因,与输入文件相比,输出文件具有令人难以置信的增益(50db!),我不知道为什么会这样。 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! 谢谢!

scipy.fftpack.irfft returns an array of floats. scipy.fftpack.irfft返回一个浮点数组。 Convert it to the dtype of your input file before writing it as wav file: output.astype(input.dtype) . 在将其写为wav文件之前将其转换为输入文件的output.astype(input.dtype)output.astype(input.dtype)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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