Spaces:
Sleeping
Sleeping
Update librosa/core/__init__.py
Browse files- librosa/core/__init__.py +8 -5
librosa/core/__init__.py
CHANGED
|
@@ -4,11 +4,13 @@
|
|
| 4 |
import tensorflow as tf
|
| 5 |
import numpy as np
|
| 6 |
|
| 7 |
-
def stft(y, n_fft=2048, hop_length=512, win_length=2048, center=True):
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
y = tf.convert_to_tensor(y, dtype=tf.float32)
|
| 10 |
|
| 11 |
-
# Produce STFT
|
| 12 |
Z = tf.signal.stft(
|
| 13 |
y,
|
| 14 |
frame_length=win_length,
|
|
@@ -19,10 +21,10 @@ def stft(y, n_fft=2048, hop_length=512, win_length=2048, center=True):
|
|
| 19 |
)
|
| 20 |
return Z.numpy()
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
Z = tf.convert_to_tensor(Z, dtype=tf.complex64)
|
| 24 |
|
| 25 |
-
# Inverse STFT
|
| 26 |
audio = tf.signal.inverse_stft(
|
| 27 |
Z,
|
| 28 |
frame_length=win_length,
|
|
@@ -30,3 +32,4 @@ def istft(Z, hop_length=512, win_length=2048):
|
|
| 30 |
window_fn=tf.signal.hann_window
|
| 31 |
)
|
| 32 |
return audio.numpy()
|
|
|
|
|
|
| 4 |
import tensorflow as tf
|
| 5 |
import numpy as np
|
| 6 |
|
| 7 |
+
def stft(y, n_fft=2048, hop_length=512, win_length=2048, center=True, window=None, **kwargs):
|
| 8 |
+
"""
|
| 9 |
+
Minimal STFT stub compatible with Spleeter.
|
| 10 |
+
Ignores the `window` argument because we always use Hann window.
|
| 11 |
+
"""
|
| 12 |
y = tf.convert_to_tensor(y, dtype=tf.float32)
|
| 13 |
|
|
|
|
| 14 |
Z = tf.signal.stft(
|
| 15 |
y,
|
| 16 |
frame_length=win_length,
|
|
|
|
| 21 |
)
|
| 22 |
return Z.numpy()
|
| 23 |
|
| 24 |
+
|
| 25 |
+
def istft(Z, hop_length=512, win_length=2048, window=None, **kwargs):
|
| 26 |
Z = tf.convert_to_tensor(Z, dtype=tf.complex64)
|
| 27 |
|
|
|
|
| 28 |
audio = tf.signal.inverse_stft(
|
| 29 |
Z,
|
| 30 |
frame_length=win_length,
|
|
|
|
| 32 |
window_fn=tf.signal.hann_window
|
| 33 |
)
|
| 34 |
return audio.numpy()
|
| 35 |
+
|