Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is tf.signal.stft same as librosa.stft ? #32373

Closed
ucasiggcas opened this issue Sep 10, 2019 · 4 comments
Closed

is tf.signal.stft same as librosa.stft ? #32373

ucasiggcas opened this issue Sep 10, 2019 · 4 comments
Assignees
Labels
comp:ops OPs related issues type:support Support issues

Comments

@ucasiggcas
Copy link

hi,
Dear, if I use the tf.signal.stft instead of librosa.stft, will have any difference ?
and tf.signal.inverse_stft could be librosa.istft ?

thanks a lot

@oanush oanush self-assigned this Sep 11, 2019
@oanush oanush added comp:ops OPs related issues type:support Support issues labels Sep 11, 2019
@oanush oanush assigned jvishnuvardhan and unassigned oanush Sep 11, 2019
@jvishnuvardhan
Copy link
Contributor

This is not Build/Installation or Bug/Performance issue. Please post this kind of support questions at Stackoverflow. There is a big community to support and learn from your questions. GitHub is mainly for addressing bugs in installation and performance. Thanks!

@tensorflow-bot
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@ucasiggcas
Copy link
Author

Are you satisfied with the resolution of your issue?
Yes
No

NO
Can't open the link

@carlthome
Copy link
Contributor

They're different and you cannot just replace one with the other. This is pretty easy to test.

import librosa as lr
import tensorflow as tf

waveform, samplerate = lr.load(lr.util.example_audio_file(), None, duration=10.0)

z1 = lr.stft(waveform)
z2 = tf.signal.stft(waveform, 2048, 512).numpy()
print(z1.shape, z1.min(), z1.max(), z1.mean())
print(z2.shape, z2.min(), z2.max(), z2.mean())

Aside from the transpose, librosa does reflect padding to center analysis frames (np.pad(waveform, 2048//2, 'reflect')). That seems to be the major difference, but even after matching that you'd still get some slightly different values (perhaps the underlying FFT isn't identical). They're different enough that you cannot just drop-in replace one for the other with a pretrained model so beware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues type:support Support issues
Projects
None yet
Development

No branches or pull requests

4 participants