MCPcopy Create free account
hub / github.com/espnet/espnet / stft

Function stft

espnet2/legacy/transform/spectrogram.py:7–41  ·  view source on GitHub ↗

Process STFT from signal.

(
    x, n_fft, n_shift, win_length=None, window="hann", center=True, pad_mode="reflect"
)

Source from the content-addressed store, hash-verified

5
6
7def stft(
8 x, n_fft, n_shift, win_length=None, window="hann", center=True, pad_mode="reflect"
9):
10 """Process STFT from signal."""
11 # x: [Time, Channel]
12 if x.ndim == 1:
13 single_channel = True
14 # x: [Time] -> [Time, Channel]
15 x = x[:, None]
16 else:
17 single_channel = False
18 x = x.astype(np.float32)
19
20 # FIXME(kamo): librosa.stft can't use multi-channel?
21 # x: [Time, Channel, Freq]
22 x = np.stack(
23 [
24 librosa.stft(
25 x[:, ch],
26 n_fft=n_fft,
27 hop_length=n_shift,
28 win_length=win_length,
29 window=window,
30 center=center,
31 pad_mode=pad_mode,
32 ).T
33 for ch in range(x.shape[1])
34 ],
35 axis=1,
36 )
37
38 if single_channel:
39 # x: [Time, Channel, Freq] -> [Time, Freq]
40 x = x[:, 0]
41 return x
42
43
44def istft(x, n_shift, win_length=None, window="hann", center=True):

Callers 14

spectrogramFunction · 0.85
logmelspectrogramFunction · 0.85
__call__Method · 0.85
spectrogramMethod · 0.85
wpe_workerFunction · 0.85
wpe_workerFunction · 0.85
run_wpe.pyFile · 0.85
run_wpe.pyFile · 0.85
scoringFunction · 0.85
test_get_rtfFunction · 0.85
test_gevdFunction · 0.85

Calls

no outgoing calls

Tested by 5

test_get_rtfFunction · 0.68
test_gevdFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…