Signal_Analysis.
get_F_0
(signal, rate, time_step=0.04, min_pitch=75, max_pitch=600, max_num_cands=15, silence_threshold=0.03, voicing_threshold=0.45, octave_cost=0.01, octave_jump_cost=0.35, voiced_unvoiced_cost=0.14, accurate=False, pulse=False)Compute Fundamental Frequency (F0). Algorithm filters out values higher than the Nyquist Frequency, then segments the signal into frames containing at least 3 periods of the minimum pitch. For each frame it then calculates autocorrelation of the signal. After autocorrelation is calculated the maxima values are found. Once these values have been chosen the best candidate for the F0 is picked and then returned. This algorithm is adapted from http://www.fon.hum.uva.nl/david/ba_shs/2010/Boersma_Proceedings_1993.pdf
signal (numpy.ndarray): The signal the fundamental frequency will be calculated from.
rate (int): the rate per seconds that the signal was sampled at.
time_step (float): (default value: 0.04) the measurement interval (frame duration), in seconds. If you supply 0, Praat will use a time step of 0.75 / (min_pitch), e.g. 0.01 seconds if the minimum pitch is 75 Hz; in this example, algorithm computes 100 pitch values per second.
min_pitch (float): (default value: 75) minimum value to be returned as pitch, cannot be less than or equal to zero
max_pitch (float): (default value: 600) maximum value to be returned as pitch, cannot be greater than Nyquist Frequency
max_num_cands (int): (default value: 15) maximum number of candidates to be considered for each frame, unvoiced candidate (i.e. F_0 equal to zero) is always considered.
silence_threshold (float): (default value: 0.03) frames that do not contain amplitudes above this threshold (relative to the global maximum amplitude), are probably silent.
voicing_threshold (float): (default value: 0.45) the strength of the unvoiced candidate, relative to the maximum possible autocorrelation. To increase the number of unvoiced decisions, increase this value.
octave_cost (float): (default value: 0.01 per octave) degree of favouring of high-frequency candidates, relative to the maximum possible autocorrelation. This is necessary because in the case of a perfectly periodic signal, all undertones of F0 are equally strong candidates as F0 itself. To more strongly favour recruitment of high-frequency candidates, increase this value.
octave_jump_cost (float): (default value: 0.35) degree of disfavouring of pitch changes, relative to the maximum possible autocorrelation. To decrease the number of large frequency jumps, increase this value.
voiced_unvoiced_cost (float): (default value: 0.14) degree of disfavouring of voiced/unvoiced transitions, relative to the maximum possible autocorrelation. To decrease the number of voiced/unvoiced transitions, increase this value.
accurate (bool): (default value: False) if false, the window is a Hanning window with a physical length of 3 / (min_pitch). If on, the window is a Gaussian window with a physical length of 6 / (min_pitch), i.e. twice the effective length.
pulse (bool): (default value: False) if false, returns the median F_0, if True, returns the frequencies for each frame in a list and also a list of tuples containing the beginning time of the frame, and the ending time of the frame. The indicies in each list correspond to each other.
ValueError: The maximum pitch cannot be greater than the Nyquist Frequency.
ValueError: The minimum pitch cannot be equal or less than zero.
ValueError: The minimum number of candidates is 2.
ValueError: octave_cost must be between 0 and 1.
ValueError: silence_threshold must be between 0 and 1.
ValueError: voicing_threshold must be between 0 and 1.
Example:
from scipy.io import wavfile as wav
import Signal_Analysis as sig
rate, wave = wav.read( 'example_audio_file.wav' )
sig.get_F_0( wave, rate )
Signal_Analysis.
get_HNR
(signal, rate, time_step=0.01, min_pitch=75, silence_threshold=0.1, periods_per_window=4.5)Compute Fundamental Frequency (F_0). Algorithm filters out values higher than the Nyquist Frequency, then segments the signal into frames containing at least 3 periods of the minimum pitch. For each frame it then calculates autocorrelation of the signal. After autocorrelation is calculated the maxima values are found. Once these values have been chosen the best candidate for the F_0 is picked and then returned. This algorithm is adapted from http://www.fon.hum.uva.nl/david/ba_shs/2010/Boersma_Proceedings_1993.pdf
signal (numpy.ndarray): The signal the fundamental frequency will be calculated from.
rate (int): the rate per seconds that the signal was sampled at.
min_pitch (float): (default value: 75) minimum value to be returned as pitch, cannot be less than or equal to zero
silence_threshold (float): (default value: 0.1) frames that do not contain amplitudes above this threshold (relative to the global maximum amplitude), are considered silent.
periods_per_window (float): (default value: 4.5) 4.5 is best for speech: HNR values up to 37 dB are guaranteed to be detected reliably; 6 periods per window raises this figure to more than 60 dB, but the algorithm becomes more sensitive to dynamic changes in the signal.
ValueError: The minimum pitch cannot be equal or less than zero.
ValueError: silence_threshold must be between 0 and 1.
Example:
from scipy.io import wavfile as wav
import Signal_Analysis as sig
rate, wave = wav.read( 'example_audio_file.wav' )
sig.get_F_0( wave, rate )
Signal_Analysis.
get_Jitter
(signal, rate, period_floor=0.0001, period_ceiling=0.02, max_period_factor=1.3)Compute Jitter, random pertubations in period length. Algorithm filters out values higher than the Nyquist Frequency, then segments the signal into frames containing at least 3 periods of period ceiling. For each frame it calculates absolute jitter, relative jitter, relative average perturbation (rap), the 5- point period pertubation quotient (ppq5), and the difference of differences of periods (ddp). After each type of jitter has been calculated for each frame the best candidate for each type is chosen and returned in a dictionary. This algorithm is adapted from http://www.lsi.upc.edu/~nlp/papers/far_jit_07.pdf
signal (numpy.ndarray): The signal the fundamental frequency will be calculated from.
rate (int): the rate per seconds that the signal was sampled at.
period_floor (float): (default value: .0001) the shortest possible interval that will be used in the computation of jitter, in seconds. If an interval is shorter than this, it will be ignored in the computation of jitter (and the previous and next intervals will not be regarded as consecutive). This setting will normally be very small, say 0.1 ms.
period_ceiling (float): (default value: .02) the longest possible interval that will be used in the computation of jitter, in seconds. If an interval is longer than this, it will be ignored in the computation of jitter (and the previous and next intervals will not be regarded as consecutive). For example, if the minimum frequency of periodicity is 50 Hz, set this setting to 0.02 seconds; intervals longer than that could be regarded as voiceless stretches and will be ignored in the computation.
max_period_factor (float): (default value: 1.3) the largest possible difference between consecutive intervals that will be used in the computation of jitter. If the ratio of the durations of two consecutive intervals is greater than this, this pair of intervals will be ignored in the computation of jitter (each of the intervals could still take part in the computation of jitter in a comparison with its neighbour on the other side).
Example:
from scipy.io import wavfile as wav
import Signal_Analysis as sig
rate, wave = wav.read( 'example_audio_file.wav' )
sig.get_Jitter( wave, rate )
Signal_Analysis.
get_Pulses
(signal, rate, min_pitch=75, max_pitch=600, include_maxima=False, include_minima=True)This algorithm examines voiced intervals of a signal, and creates a list of points that correspond to the sequence of glottal closures in vocal-fold vibration. adapted from: https://pdfs.semanticscholar.org/16d5/980ba1cf168d5782379692517250e80f0082.pdf
signal (numpy.ndarray): The signal the fundamental frequency will be calculated from.
rate (int): the rate per seconds that the signal was sampled at.
min_pitch (float): (default value: 75) minimum value to be returned as pitch, cannot be less than or equal to zero
max_pitch (float): (default value: 600) maximum value to be returned as pitch, cannot be greater than Nyquist Frequency
Example:
from scipy.io import wavfile as wav
import Signal_Analysis as sig
rate, wave = wav.read( 'example_audio_file.wav' )
sig.get_Pulses( wave, rate )