matplotlib moved to local import

This commit is contained in:
Fabio Manganiello 2020-10-28 19:16:51 +01:00
parent d867880199
commit 85f99e7362
2 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,6 @@
from typing import Optional, Union from typing import Optional
import numpy as np import numpy as np
import matplotlib.pyplot as plt
class AudioSegment: class AudioSegment:
@ -30,11 +29,13 @@ class AudioSegment:
]) ])
def plot_audio(self): def plot_audio(self):
import matplotlib.pyplot as plt
plt.plot(self.audio) plt.plot(self.audio)
plt.show() plt.show()
def plot_spectrum(self, low_freq: int = default_low_freq, high_freq: int = default_high_freq, def plot_spectrum(self, low_freq: int = default_low_freq, high_freq: int = default_high_freq,
bins: int = default_bins): bins: int = default_bins):
import matplotlib.pyplot as plt
spectrum = self.spectrum(low_freq=low_freq, high_freq=high_freq, bins=bins) spectrum = self.spectrum(low_freq=low_freq, high_freq=high_freq, bins=bins)
plt.ylim(0, 1) plt.ylim(0, 1)
plt.bar(range(len(spectrum)), spectrum) plt.bar(range(len(spectrum)), spectrum)

View File

@ -1,3 +1,4 @@
numpy numpy
tensorflow tensorflow
keras keras
matplotlib