Skip to content

Commit b1f47c2

Browse files
committed
set default align target param to MFCC
1 parent b9bc0ec commit b1f47c2

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ from mel_cepstral_distance import compare_audio_files
3333

3434
mcd, penalty = compare_audio_files(
3535
'examples/GT.wav',
36-
'examples/WaveGlow.wav',
36+
'examples/Tacotron-2.wav',
3737
)
3838

3939
print(f'MCD: {mcd:.2f}, Penalty: {penalty:.4f}')
40-
# MCD: 4.03, Penalty: 0.0197
40+
# MCD: 7.45, Penalty: 0.1087
4141
```
4242

4343
## Calculation

src/mel_cepstral_distance/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def compare_audio_files(
398398
s: int = 1,
399399
D: int = 16,
400400
aligning: Literal["pad", "dtw"] = "dtw",
401-
align_target: Literal["spec", "mel", "mfcc"] = "mel",
401+
align_target: Literal["spec", "mel", "mfcc"] = "mfcc",
402402
remove_silence: Literal["no", "sig", "spec", "mel", "mfcc"] = "no",
403403
silence_threshold_A: Optional[float] = None,
404404
silence_threshold_B: Optional[float] = None,
@@ -649,7 +649,7 @@ def compare_amplitude_spectrograms(
649649
s: int = 1,
650650
D: int = 16,
651651
aligning: Literal["pad", "dtw"] = "dtw",
652-
align_target: Literal["spec", "mel", "mfcc"] = "spec",
652+
align_target: Literal["spec", "mel", "mfcc"] = "mfcc",
653653
remove_silence: Literal["no", "spec", "mel", "mfcc"] = "no",
654654
silence_threshold_A: Optional[float] = None,
655655
silence_threshold_B: Optional[float] = None,
@@ -879,7 +879,7 @@ def compare_mel_spectrograms(
879879
s: int = 1,
880880
D: int = 16,
881881
aligning: Literal["pad", "dtw"] = "dtw",
882-
align_target: Literal["mel", "mfcc"] = "mel",
882+
align_target: Literal["mel", "mfcc"] = "mfcc",
883883
remove_silence: Literal["no", "mel", "mfcc"] = "no",
884884
silence_threshold_A: Optional[float] = None,
885885
silence_threshold_B: Optional[float] = None,

src/mel_cepstral_distance_tests/api_tests/test_compare_amplitude_spectrograms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,17 @@ def test_no_freq_bins_raises_error() -> None:
376376

377377

378378
def test_invalid_radius_raises_error() -> None:
379-
with pytest.raises(ValueError):
379+
with pytest.raises(
380+
ValueError, match="dtw_radius must be None or greater than or equal to 1"
381+
):
380382
compare_amplitude_spectrograms(
381383
get_X_km_A(),
382384
get_X_km_B(),
383385
22050,
384386
samples_to_ms(512, 22050),
385387
dtw_radius=0,
386388
aligning="dtw",
389+
align_target="spec",
387390
)
388391

389392

src/mel_cepstral_distance_tests/api_tests/test_compare_audio_files.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,9 @@ def test_invalid_remove_silence_raises_error() -> None:
559559

560560

561561
def test_invalid_radius_raises_error() -> None:
562-
with pytest.raises(ValueError):
562+
with pytest.raises(
563+
ValueError, match="dtw_radius must be None or greater than or equal to 1"
564+
):
563565
compare_audio_files(AUDIO_A, AUDIO_B, aligning="dtw", dtw_radius=0)
564566

565567

src/mel_cepstral_distance_tests/api_tests/test_compare_mel_spectrograms.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ def test_same_spec_returns_zero() -> None:
131131

132132

133133
def test_invalid_radius_raises_error() -> None:
134-
with pytest.raises(ValueError):
135-
compare_mel_spectrograms(get_X_kn_A(), get_X_kn_B(), aligning="dtw", dtw_radius=0)
134+
with pytest.raises(
135+
ValueError, match="dtw_radius must be None or greater than or equal to 1"
136+
):
137+
compare_mel_spectrograms(
138+
get_X_kn_A(), get_X_kn_B(), aligning="dtw", align_target="mel", dtw_radius=0
139+
)
136140

137141

138142
def test_removing_silence_from_mel_too_hard_returns_nan_nan() -> None:

0 commit comments

Comments
 (0)