本文介绍了rfft或irfft增加python中的wav文件量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始编写程序来处理python中的某些音频.在编写任何滤波功能之前,我想做一个测试,以在输入信号经过rfft和irfft之后将输入信号与输出信号进行比较.由于某种原因,与输入文件相比,输出文件具有令人难以置信的增益(50db!),我不知道为什么会这样.这是代码:
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)
谢谢!
推荐答案
scipy.fftpack.irfft
返回一个浮点数数组.将其转换为输入文件的dtype,然后将其写入wav文件:output.astype(input.dtype)
.
这篇关于rfft或irfft增加python中的wav文件量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!