For the audio file found here, I am using the ssqueezepy
library in Python to generate the cwt of the signal. Here is my Python code:
import librosa
import librosa.display
import numpy as np
from ssqueezepy import cwt
from ssqueezepy.visuals import plot, imshow
import numpy as np
import matplotlib.pyplot as plt
import soundfile as sf
# Set the path to the Binary Class dataset
input_file = (r'G:/audio/AWCK AR AK 47 Close 01_trim-pt5_16bit_norm-1_Mono.wav')
[data1, sample_rate1] = sf.read(input_file)
#[sample_rate1, data1] = wav.read(input_file);
duration = len(data1)/sample_rate1
time = np.arange(0, duration, 1/sample_rate1) #time vector
#%%############## Take CWT & plot ##################################################
Wx, scales = cwt(data1, 'morlet')
imshow(Wx, yticks=scales, abs=1,
title="abs(CWT) | Morlet wavelet",
ylabel="scales", xlabel="samples")
plt.show()
Here is the resulting scalogram:
When I use Matlab:
%% preparing dataset
input_file = ['G:\audio\AWCK AR AK 47 Close 01_trim-pt5_16bit_norm-1_Mono.wav'];
[y,Fs] = audioread(input_file);
%% Display scalogram
cwt(y, "bump", Fs)
I get this plot:
When you look at the y-axis, Python has the y-axis inverted but then both the Python and Matlab plot looks similar.
Can you give an explanation as to why there is a difference? How to make Python match up with Matlab on the axis perspective?