Unverified Commit 20a4313d authored by Dan Ellis's avatar Dan Ellis Committed by GitHub
Browse files

Merge pull request #3378 from plakal/master

Cosmetic changes to spectrogram_to_mel_matrix()
parents 3e9e7a60 bdf0f628
...@@ -150,7 +150,7 @@ def spectrogram_to_mel_matrix(num_mel_bins=20, ...@@ -150,7 +150,7 @@ def spectrogram_to_mel_matrix(num_mel_bins=20,
An np.array with shape (num_spectrogram_bins, num_mel_bins). An np.array with shape (num_spectrogram_bins, num_mel_bins).
Raises: Raises:
ValueError: if frequency edges are incorrectly ordered. ValueError: if frequency edges are incorrectly ordered or out of range.
""" """
nyquist_hertz = audio_sample_rate / 2. nyquist_hertz = audio_sample_rate / 2.
if lower_edge_hertz < 0.0: if lower_edge_hertz < 0.0:
...@@ -160,7 +160,7 @@ def spectrogram_to_mel_matrix(num_mel_bins=20, ...@@ -160,7 +160,7 @@ def spectrogram_to_mel_matrix(num_mel_bins=20,
(lower_edge_hertz, upper_edge_hertz)) (lower_edge_hertz, upper_edge_hertz))
if upper_edge_hertz > nyquist_hertz: if upper_edge_hertz > nyquist_hertz:
raise ValueError("upper_edge_hertz %.1f is greater than Nyquist %.1f" % raise ValueError("upper_edge_hertz %.1f is greater than Nyquist %.1f" %
(upper_edge_hertz, nyquist_hertz)) (upper_edge_hertz, nyquist_hertz))
spectrogram_bins_hertz = np.linspace(0.0, nyquist_hertz, num_spectrogram_bins) spectrogram_bins_hertz = np.linspace(0.0, nyquist_hertz, num_spectrogram_bins)
spectrogram_bins_mel = hertz_to_mel(spectrogram_bins_hertz) spectrogram_bins_mel = hertz_to_mel(spectrogram_bins_hertz)
# The i'th mel band (starting from i=1) has center frequency # The i'th mel band (starting from i=1) has center frequency
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment