Function
spectrogram_func_librosa
(nfft, win_len, win_step, window, center, input_data)
Source from the content-addressed store, hash-verified
| 93 | |
| 94 | |
| 95 | def spectrogram_func_librosa(nfft, win_len, win_step, window, center, input_data): |
| 96 | # Squeeze to 1d |
| 97 | if len(input_data.shape) > 1: |
| 98 | input_data = np.squeeze(input_data) |
| 99 | |
| 100 | if window is None: |
| 101 | window = hann_win |
| 102 | |
| 103 | out = ( |
| 104 | np.abs( |
| 105 | stft( |
| 106 | y=input_data, |
| 107 | n_fft=nfft or win_len, |
| 108 | center=center, |
| 109 | win_length=win_len, |
| 110 | hop_length=win_step, |
| 111 | window=window, |
| 112 | pad_mode="reflect", |
| 113 | ) |
| 114 | ) |
| 115 | ** 2 |
| 116 | ) |
| 117 | |
| 118 | # Alternative way to calculate the spectrogram: |
| 119 | # out, _ = librosa.core.spectrum._spectrogram( |
| 120 | # y=input_data, n_fft=nfft, hop_length=win_step, window=hann_win, power=2) |
| 121 | |
| 122 | return out |
| 123 | |
| 124 | |
| 125 | class SpectrogramPythonPipeline(Pipeline): |
Callers
nothing calls this directly
Tested by
no test coverage detected