Python and PySoundFile

A short Python program to show the waveform from a sound file.

import sys
import numpy as np
import matplotlib.pyplot as plt
import soundfile as sf

filename = sys.argv[1]
nsbegin  = int(sys.argv[2])
nsend    = int(sys.argv[3])

wav, fs  = sf.read(filename)

plt.plot(wav[nsbegin:nsend], color='green')
plt.title("input signal")
plt.xlabel("time")
plt.ylabel("amplitude")

plt.show()

Leave a Reply

Your email address will not be published. Required fields are marked *