我正在工作的程序的概念是一个Python模块,它可以检测特定的频率(人类语音频率80-300 of ),并通过从数据库中进行检查来显示句子的语调。我使用SciPy来绘制声音文件的频率,但是我不能设置任何特定的频率来分析音高。我该怎么做呢?
更多信息:我希望能够在语音中设置定义的模式(例如,上升,下降),程序会检测声音文件是否遵循特定的模式。
发布于 2015-09-16 05:09:36
您可以尝试执行以下操作。我相信你知道人类的声音也有超过300赫兹的谐波。然而,您可以在音频文件中移动窗口,并尝试查看窗口中的最大功率(如下所示)或一组频率的变化。下面的代码是用于给出直觉的:
import scipy.fftpack as sf
import numpy as np
def maxFrequency(X, F_sample, Low_cutoff=80, High_cutoff= 300):
""" Searching presence of frequencies on a real signal using FFT
Inputs
=======
X: 1-D numpy array, the real time domain audio signal (single channel time series)
Low_cutoff: float, frequency components below this frequency will not pass the filter (physical frequency in unit of Hz)
High_cutoff: float, frequency components above this frequency will not pass the filter (physical frequency in unit of Hz)
F_sample: float, the sampling frequency of the signal (physical frequency in unit of Hz)
"""
M = X.size # let M be the length of the time series
Spectrum = sf.rfft(X, n=M)
[Low_cutoff, High_cutoff, F_sample] = map(float, [Low_cutoff, High_cutoff, F_sample])
#Convert cutoff frequencies into points on spectrum
[Low_point, High_point] = map(lambda F: F/F_sample * M, [Low_cutoff, High_cutoff])
maximumFrequency = np.where(Spectrum == np.max(Spectrum[Low_point : High_point])) # Calculating which frequency has max power.
return maximumFrequency
voiceVector = []
for window in fullAudio: # Run a window of appropriate length across the audio file
voiceVector.append (maxFrequency( window, samplingRate))
现在,根据声音的语调,最大功率频率可能会发生变化,您可以注册并映射到给定的语调。这可能不一定总是正确的,您可能必须一起监控许多频率的变化,但这应该可以让您开始。
发布于 2015-11-02 09:03:31
2019年更新,现在有基于神经网络的非常精确的基音跟踪器。而且它们开箱即用Python。检查
https://pypi.org/project/crepe/
2015年的答案。基音检测是一个复杂的问题,Google的最新软件包为这项非琐碎的任务提供了高度智能的解决方案:
https://github.com/google/REAPER
如果您想要从Python访问它,可以将它包装在Python中。
发布于 2019-03-27 01:52:55
有许多不同的算法来估计音调,但一项研究发现,普拉特的算法是最准确的1。最近,Parselmouth库使得从Python2中调用普拉特函数变得容易得多。
1:斯特伦伯格松,索非亚。目前最常用的F0估计方法,以及它们在清洁语音中估计男女基音的准确性。对讲机。2016年。https://pdfs.semanticscholar.org/ff04/0316f44eab5c0497cec280bfb1fd0e7c0e85.pdf
https://stackoverflow.com/questions/32595404
复制相似问题