Understand numpy.hanning() for Audio Processing in Python – Python Tutorial

By | December 1, 2021

numpy.hanning() is a window function that often be used in python audio processing. In this tutorial, we will introduce it for beginners.

numpy.hanning()

numpy.hanning() is defined as:

numpy.hanning(M)

It will return a ndarray, shape(M,).

The value of the output is computed as:

understand numpy.hanning() function

For example: np.hanning(51) looks like:

the example of numpy.hanning()

How to use numpy.hanning() to process audio in python?

In python audio processing, we can use this function to hide the beginning and the end of audio data in an audio file.

For example, we often use python python_speech_features package to extract audio feature: mfcc or fbank.

def fbank(signal,samplerate=16000,winlen=0.025,winstep=0.01,
          nfilt=26,nfft=512,lowfreq=0,highfreq=None,preemph=0.97,
          winfunc=lambda x:numpy.ones((x,))):

Here we can use numpy.hanning() to winfunc.

winfunc = np.hanning

Here is a tutorial:

Python Extract Audio Fbank Feature for Training – Python Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *