mirror of https://github.com/coqui-ai/TTS.git
plot spectrograms undenormalized if no ap is provided
This commit is contained in:
parent
f3d4d1f831
commit
f18f6e6d3e
|
@ -27,14 +27,15 @@ def plot_alignment(alignment, info=None, fig_size=(16, 10), title=None):
|
|||
return fig
|
||||
|
||||
|
||||
def plot_spectrogram(linear_output, audio, fig_size=(16, 10)):
|
||||
if isinstance(linear_output, torch.Tensor):
|
||||
linear_output_ = linear_output.detach().cpu().numpy().squeeze()
|
||||
def plot_spectrogram(spectrogram, ap=None, fig_size=(16, 10)):
|
||||
if isinstance(spectrogram, torch.Tensor):
|
||||
spectrogram_ = spectrogram.detach().cpu().numpy().squeeze()
|
||||
else:
|
||||
linear_output_ = linear_output
|
||||
spectrogram = audio._denormalize(linear_output_.T) # pylint: disable=protected-access
|
||||
spectrogram_ = spectrogram
|
||||
if ap is not None:
|
||||
spectrogram_ = ap._denormalize(spectrogram_.T) # pylint: disable=protected-access
|
||||
fig = plt.figure(figsize=fig_size)
|
||||
plt.imshow(spectrogram, aspect="auto", origin="lower")
|
||||
plt.imshow(spectrogram_, aspect="auto", origin="lower")
|
||||
plt.colorbar()
|
||||
plt.tight_layout()
|
||||
return fig
|
||||
|
|
Loading…
Reference in New Issue