2018-02-04 08:25:00 -08:00
|
|
|
import numpy as np
|
|
|
|
|
import matplotlib
|
|
|
|
|
matplotlib.use('Agg')
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def plot_alignment(alignment, info=None):
|
2018-04-03 03:24:57 -07:00
|
|
|
fig, ax = plt.subplots(figsize=(16, 10))
|
2018-08-02 16:34:17 +02:00
|
|
|
im = ax.imshow(
|
|
|
|
|
alignment.T, aspect='auto', origin='lower', interpolation='none')
|
2018-02-04 08:25:00 -08:00
|
|
|
fig.colorbar(im, ax=ax)
|
|
|
|
|
xlabel = 'Decoder timestep'
|
|
|
|
|
if info is not None:
|
|
|
|
|
xlabel += '\n\n' + info
|
|
|
|
|
plt.xlabel(xlabel)
|
|
|
|
|
plt.ylabel('Encoder timestep')
|
|
|
|
|
plt.tight_layout()
|
2018-08-11 16:53:09 +02:00
|
|
|
return fig
|
2018-02-04 08:25:00 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def plot_spectrogram(linear_output, audio):
|
|
|
|
|
spectrogram = audio._denormalize(linear_output)
|
|
|
|
|
fig = plt.figure(figsize=(16, 10))
|
|
|
|
|
plt.imshow(spectrogram.T, aspect="auto", origin="lower")
|
|
|
|
|
plt.colorbar()
|
|
|
|
|
plt.tight_layout()
|
2018-08-11 16:53:09 +02:00
|
|
|
return fig
|