Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace positional argument with keyword arg in spectrograms #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion surfboard/misc_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def get_bark_spectrogram(waveform, sample_rate, n_fft_seconds, hop_length_second
hop_length = numseconds_to_numsamples(hop_length_seconds, sample_rate)

# [n_frequency_bins, t]
spectrogram, _ = librosa.core.spectrum._spectrogram(waveform, n_fft=n_fft, hop_length=hop_length)
spectrogram, _ = librosa.core.spectrum._spectrogram(y=waveform, n_fft=n_fft, hop_length=hop_length)
frequencies = librosa.core.fft_frequencies(sr=sample_rate, n_fft=n_fft)

assert spectrogram.shape[0] == frequencies.shape[0], "Different number of frequencies..."
Expand Down
4 changes: 2 additions & 2 deletions surfboard/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def log_melspec(self, n_mels=128, n_fft_seconds=0.04, hop_length_seconds=0.01):
hop_length = numseconds_to_numsamples(hop_length_seconds, self.sample_rate)

melspec = librosa.feature.melspectrogram(
self.waveform, sr=self.sample_rate, n_mels=n_mels, n_fft=n_fft, hop_length=hop_length,
y=self.waveform, sr=self.sample_rate, n_mels=n_mels, n_fft=n_fft, hop_length=hop_length,
)
return librosa.power_to_db(melspec, ref=np.max)

Expand All @@ -171,7 +171,7 @@ def magnitude_spectrum(self, n_fft_seconds=0.04, hop_length_seconds=0.01):
n_fft = numseconds_to_numsamples(n_fft_seconds, self.sample_rate)
hop_length = numseconds_to_numsamples(hop_length_seconds, self.sample_rate)

mag_spectrum, _ = librosa.core.spectrum._spectrogram(self.waveform, n_fft=n_fft, hop_length=hop_length)
mag_spectrum, _ = librosa.core.spectrum._spectrogram(y=self.waveform, n_fft=n_fft, hop_length=hop_length)
return mag_spectrum

def bark_spectrogram(self, n_fft_seconds=0.04, hop_length_seconds=0.01):
Expand Down