Skip to content

Commit

Permalink
note windows isssue
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileGoat committed Sep 6, 2022
1 parent c2a86d9 commit 4914c02
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions python/paddle/tests/test_audio_logmel_feature.py
Expand Up @@ -87,13 +87,16 @@ def test_log_melspect(self, sr: int, window_str: str, n_fft: int,
feature_layer,
decimal=3)

@parameterize([16000, 8000], [256, 128], [40, 64], [64, 128])
def test_mfcc(self, sr: int, n_fft: int, n_mfcc: int, n_mels: int):
@parameterize([16000], [256, 128], [40, 64], [64, 128],
["float32", "float64"])
def test_mfcc(self, sr: int, n_fft: int, n_mfcc: int, n_mels: int,
numtype: str):
if len(self.waveform.shape) == 2: # (C, T)
self.waveform = self.waveform.squeeze(
0) # 1D input for librosa.feature.melspectrogram

# librosa:
np_dtype = getattr(np, numtype)
feature_librosa = librosa.feature.mfcc(y=self.waveform,
sr=sr,
S=None,
Expand All @@ -103,10 +106,12 @@ def test_mfcc(self, sr: int, n_fft: int, n_mfcc: int, n_mels: int):
n_fft=n_fft,
hop_length=64,
n_mels=n_mels,
fmin=50.0)
fmin=50.0,
dtype=np_dtype)
# paddlespeech.audio.features.layer
x = paddle.to_tensor(self.waveform, dtype=paddle.float64).unsqueeze(
0) # Add batch dim.
paddle_dtype = getattr(paddle, numtype)
x = paddle.to_tensor(self.waveform,
dtype=paddle_dtype).unsqueeze(0) # Add batch dim.
feature_extractor = paddle.audio.features.MFCC(sr=sr,
n_mfcc=n_mfcc,
n_fft=n_fft,
Expand All @@ -118,7 +123,7 @@ def test_mfcc(self, sr: int, n_fft: int, n_mfcc: int, n_mels: int):

np.testing.assert_array_almost_equal(feature_librosa,
feature_layer,
decimal=2)
decimal=1)


if __name__ == '__main__':
Expand Down

0 comments on commit 4914c02

Please sign in to comment.