简体   繁体   English

如何从 python 中的 WAV 文件中提取不同的频率?

[英]How to extract different frequencies from a WAV file in python?


I'm trying to play different frequencies at equal time intervals from one computer and analyze them with another. 我正在尝试从一台计算机以相等的时间间隔播放不同的频率,并用另一台计算机对其进行分析。
So far I have managed to play frequencies, record them from the other computer and save them in a WAV file using Python. 到目前为止,我已经设法播放频率,从另一台计算机记录它们并使用 Python 将它们保存在 WAV 文件中。
My problem starts when I'm trying to analyze the file. 当我尝试分析文件时,我的问题就开始了。 I had tried a lot of methods I found online, but none of them have worked. 我尝试了很多我在网上找到的方法,但都没有奏效。
Can someone please recommend a library or an algorithm that fits this description? 有人可以推荐一个适合这个描述的库或算法吗? :) :)

This is what I've got:这就是我所拥有的:

 def getFreq(start): end = start + 10 sr, data = wavfile.read("somefile.wav") sp = int(sr * start / 1000) ep = int(sr * end / 1000) l = 10 / 1000 c = 0 for i in range(sp, ep): if data[i] < 0 and data[i + 1] > 0: c += 1 return int(c / l)

Look for implementations of STFTs (short term Fourier transform) or spectrogram visualizers.寻找 STFT(短期傅里叶变换)或频谱图可视化器的实现。

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

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