def test():
"""
little test, NOT FOR REAL USE, put target filename as first and only argument
will plot the pitch and strength v. time to screen
safety is not guaranteed.
"""
# imports specific to this test
import sys
import warnings
from scipy.io import wavfile
import matplotlib.pyplot as plt
from psola.experiment_config import ExperimentConfig
# get the data and do the estimation
filename = sys.argv[1] # filename is first command line arg
cfg = ExperimentConfig() # use default settings
with warnings.catch_warnings():
warnings.simplefilter("ignore") # ignore annoying WavFileWarning
fs, data = wavfile.read(filename)
pitch, t, strength = pitch_estimation(data, fs, cfg)
# Plot estimated pitch and strength of pitch values
f, (ax1, ax2) = plt.subplots(2, 1, sharex=True, figsize=(16,9))
ax1.plot(t, pitch); ax1.set_title('Pitch v. Time'); ax1.set_ylabel('Freq (Hz)')
ax2.plot(t, strength); ax2.set_title('Strength v. Time'); ax1.set_ylabel('Strength')
plt.show()
评论列表
文章目录