'Visualize a tensor output into a spectrogram plot

I am working with short audio memos in Python and I adjusted these to generalize the length of all the memos. To do this, I transformed the .wav file into a tensor ouput, which represents the frequencies of the memo per unit of time (as follows):

tensor([[0., 0., 0., ..., 0., 0., 0.]])

The beginning and the end contain moments of silence, which explains the 0's.

My question is: how can I visualize this output into a spectrogram plot? I would like to plot the time of the memo on the x-axis and the frequency of the memo on the y-axis. I have not found a suitable solution yet. Any help is much appreciated! Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source