MCPcopy Create free account
hub / github.com/NVIDIA/DALI / spectrogram_func_librosa

Function spectrogram_func_librosa

dali/test/python/operator_2/test_spectrogram.py:95–122  ·  view source on GitHub ↗
(nfft, win_len, win_step, window, center, input_data)

Source from the content-addressed store, hash-verified

93
94
95def 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
125class SpectrogramPythonPipeline(Pipeline):

Callers

nothing calls this directly

Calls 1

stftFunction · 0.90

Tested by

no test coverage detected