Skip to content

Commit d711d5e

Browse files
committed
Add test for MP3-in-WAV.
1 parent 1824458 commit d711d5e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
41.9 KB
Binary file not shown.

tests/test_io.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,26 @@ def test_real_mp3_parsing_with_no_channels():
12901290
assert f.read(f.frames).shape == (0, 0)
12911291

12921292

1293+
def test_mp3_in_wav_format():
1294+
"""
1295+
Test reading WAV files that contain MP3-compressed audio data
1296+
(WAVE_FORMAT_MPEGLAYER3, format tag 0x55).
1297+
1298+
This is a valid but unusual format where a WAV container holds MP3 data.
1299+
Some audio software produces files in this format.
1300+
"""
1301+
filename = os.path.join(os.path.dirname(__file__), "audio", "correct", "mp3_in_wav_44100Hz.wav")
1302+
with pedalboard.io.AudioFile(filename) as f:
1303+
assert f.samplerate == 44100
1304+
assert f.num_channels == 2
1305+
assert f.frames >= 44100 # At least 1 second of audio
1306+
1307+
# Read the audio and verify it's not silent
1308+
audio = f.read(f.frames)
1309+
assert audio.shape[0] == 2
1310+
assert np.amax(np.abs(audio)) > 0.1 # Should have actual audio content
1311+
1312+
12931313
@pytest.mark.parametrize("samplerate", [44100, 32000])
12941314
@pytest.mark.parametrize("chunk_size", [1, 2, 16])
12951315
@pytest.mark.parametrize("target_samplerate", [44100, 32000, 22050, 1234.56])

0 commit comments

Comments
 (0)