How to get 2D wavelet by pywt like stft from a wav file?

1.6k Views Asked by At

I am trying to get features from a sound file(.wav);

  1. I have tried stft to get a 2D feature(x is time, y is frequency )
  2. I have tried pywt, but got a 1D array. If I input a 1D (1000,) wav array, I got an array of (500,)
  3. How to use pywt to get a 2D feature like stft got?

Here is the stft feature result:

enter image description here

1

There are 1 best solutions below

0
On

You can use PyWavelet in following manner to get continuous wavelet transform of a audio wav file. However, the operation is little slow.

  import pywt
  import scipy.io.wavfile

  wavefile = 'path to the wavefile'
  # read the wavefile
  sampling_frequency, signal = scipy.io.wavfile.read(wavefile)
  #
  scales = (1, len(signal))
  coefficient, frequency = pywt.cwt(signal, scales, 'wavelet_type')