Tensorflow.js tf.signal.stft() Function
Last Updated :
12 May, 2021
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js.
The tf.signal.stft() function is used to compute the Short-time Fourier Transform of signals.
Syntax:
tf.signal.stft (signal, frameLength, frameStep,
fftLength?, windowFn?)
Parameters:
- signal: 1-dimensional real value tensor.
- frameLength: The window length of sample.
- frameStep: The number of samples to step.
- fftLength: the size of the FFT.
- windowFn: A callable that takes a window length.
Return Value: It returns tf.Tensor.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
const input = tf.tensor1d([3, 4, 6])
tf.signal.stft(input, 3, 1).print();
|
Output:
Tensor
[[4 + 0j, 0 + -4j, -4 + 0j],]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
const input = tf.tensor1d([1, 2, 3, 4, 5, 6, 7])
tf.signal.stft(input, 3, 1).print();
|
Output:
Tensor
[[2 + 0j, 0 + -2j, -2 + 0j],
[3 + 0j, 0 + -3j, -3 + 0j],
[4 + 0j, 0 + -4j, -4 + 0j],
[5 + 0j, 0 + -5j, -5 + 0j],
[6 + 0j, 0 + -6j, -6 + 0j]]
Reference: https://js.tensorflow.org/api/latest/#signal.stft
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...