def lpcc(self, lpcorder=None, cepsorder=None): ''' Function: lpcc Summary: Computes the linear predictive cepstral compoents. Note: Returned values are in the frequency domain. LPCC is computed through LPC. Examples: audiofile = AudioFile.open('file.wav',16000) frames = audiofile.frames(512,np.hamming) for frame in frames: frame.lpcc() Attributes: @param (self): @param (lpcorder) default=None: The input order to compute the LPC coefficents. @param (cepsorder) default=None: The output order to compute the LPCC coefficents. Returns: A list of LPCC components with size order +1 or len(seq), depending on if cepsorder is None ''' coefs, err_term = LinearPredictiveAnalysis.lpc(self, lpcorder) return LinearPredictiveAnalysis.lpcc(coefs, err_term, cepsorder)
def lsp(self,order=None,rectify=True): ''' Function: lsp Summary: Computes Line spectrum pairs ( also called line spectral frequencies [lsf]). Does not use any fancy algorithm except np.roots to solve for the zeros of the given polynom A(z) = 0.5(P(z) + Q(z)) Examples: audiofile = AudioFile.open('file.wav',16000) frames = audiofile.frames(512,np.hamming) for frame in frames: frame.lsp() Attributes: @param (self): @param (order) default=None:Order of lpc coefficients. Return array has size order + 1. Default is the length of the current frame @param (rectify) default=True: Specifies if the return values are only positive. If rectify is False it also returns the (symmetric) negative values Returns: A list of size order/ len(frames) (if nothing is specifed), which represents the line spectrum pairs. ''' coefs, _ = LinearPredictiveAnalysis.lpc(self, order) return LinearPredictiveAnalysis.lsp(coefs,rectify)
def lpc(self, order=None): ''' Function: lpc Summary: Computes for each given sequence the LPC ( Linear predictive components ) sequence. Examples: audiofile = AudioFile.open('file.wav',16000) frames = audiofile.frames(512,np.hamming) for frame in frames: frame.lpc() Attributes: @param (seq):A sequence of time-domain frames, usually obtained by .frames() @param (order) default=None: Size of the returning cepstral components. If None is given, we use len(seq) as default, otherwise order +1 Returns: A list of lpc coefficents ''' # Only return the coefficients not the error term (in [1]) return LinearPredictiveAnalysis.lpc(self, order)[0]