0

I am using

import matplotlib.pyplot as plt
from scipy.io import wavfile
import numpy as np

def graph_spectrogram(wav_file,png_file):
    rate, data = wavfile.read(wav_file)
    fig,ax = plt.subplots(1)
    fig.subplots_adjust(left=0,right=1,bottom=0,top=1)
    ax.axis('off')
    pxx, freqs, bins, im = ax.specgram(x=data, Fs=rate, noverlap=384, NFFT=512)
    ax.axis('off')
    fig.savefig(png_file, dpi=300, frameon='false')

if __name__ == '__main__': # Main function
    graph_spectrogram(file)

to convert a wave file to a fft image. All output files are 1920 x 1440 no matter the length of the audio file. How do I keep the height but have an output image width depending on length of the audio file?

Fabien Biller
  • 155
  • 1
  • 1
  • 10

0 Answers0