stft

ketos.audio.utils.misc.stft(x, rate, window=None, step=None, seg_args=None, window_func='hamming', decibel=True, compute_phase=False)[source]

Compute Short Time Fourier Transform (STFT).

Uses audio.utils.misc.segment_args() to convert the window size and step size into an even integer number of samples.

The number of points used for the Fourier Transform is equal to the number of samples in the window.

Args:
x: numpy.array

Audio signal

rate: float

Sampling rate in Hz

window: float

Window length in seconds

step: float

Step size in seconds

seg_args: dict

Input arguments for audio.utils.misc.segment_args(). Optional. If specified, the arguments window and step are ignored.

window_func: str
Window function (optional). Select between
  • bartlett

  • blackman

  • hamming (default)

  • hanning

decibel: bool

Convert to dB scale

compute_phase: bool

Compute complex phase angle. Default it False

Returns:
img: numpy.array

Short Time Fourier Transform of the input signal.

freq_max: float

Maximum frequency in Hz

num_fft: int

Number of points used for the Fourier Transform.

seg_args: dict

Input arguments used for evaluating audio.utils.misc.segment_args().

cpx_angle: numpy.array

Complex phase angle in radians. None unless compute_phase=True