Simon
Simon

Reputation: 171

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

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

Upvotes: 3

Views: 1840

Answers (1)

ravikt
ravikt

Reputation: 1058

You can use PyWavelet in following manner to get the continuous wavelet transform of an 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')

Upvotes: 4

Related Questions