Skip to content

πŸŽ› πŸ”Š A Python library for audio.

Fix MP3 files that start with ID3 tags and end with LYRICS3 blocks.

Peter Sobotcf7eb67b051f
diff --git a/pedalboard/io/AudioFile.h b/pedalboard/io/AudioFile.h
index 347c5ec..462f603 100644
--- a/pedalboard/io/AudioFile.h
+++ b/pedalboard/io/AudioFile.h
@@ -53,12 +53,12 @@ void registerPedalboardAudioFormats(juce::AudioFormatManager &manager,
// Linux. To do so, we use this flag:
if (crossPlatformOnly) {
- manager.registerFormat(new juce::MP3AudioFormat(), false);
+ manager.registerFormat(new juce::PatchedMP3AudioFormat(), false);
} else {
#if JUCE_MAC || JUCE_IOS
manager.registerFormat(new juce::CoreAudioFormat(), false);
#else
- manager.registerFormat(new juce::MP3AudioFormat(), false);
+ manager.registerFormat(new juce::PatchedMP3AudioFormat(), false);
#endif
}
}
diff --git a/pedalboard/io/ReadableAudioFile.h b/pedalboard/io/ReadableAudioFile.h
index 3bbb30a..32914ed 100644
--- a/pedalboard/io/ReadableAudioFile.h
+++ b/pedalboard/io/ReadableAudioFile.h
@@ -493,7 +493,7 @@ private:
if (PythonInputStream *stream = getPythonInputStream()) {
if (stream->isExhausted()) {
- ss << " The file may contain invalid data past or near its end. Try "
+ ss << " The file may contain invalid data near its end. Try "
"reading fewer audio frames from the file.";
}
}
diff --git a/tests/audio/correct/bad_audio_file_lyrics3.mp3 b/tests/audio/correct/bad_audio_file_lyrics3.mp3
new file mode 100644
index 0000000..f341f6c
Binary files /dev/null and b/tests/audio/correct/bad_audio_file_lyrics3.mp3 differ
diff --git a/tests/test_io.py b/tests/test_io.py
index bb7b2fc..9679e40 100644
--- a/tests/test_io.py
+++ b/tests/test_io.py
@@ -1032,6 +1032,16 @@ def test_mp3_parsing_with_lyrics3(cross_platform_formats_only: bool, lyric_data_
assert f.read(f.frames).shape[1] >= input_audio.shape[-1]
[email protected]("cross_platform_formats_only", [True, False])
+def test_real_mp3_parsing_with_lyrics3(cross_platform_formats_only: bool):
+ with pedalboard.io.ReadableAudioFile(
+ os.path.join(os.path.dirname(__file__), "audio", "correct", "bad_audio_file_lyrics3.mp3"),
+ cross_platform_formats_only=cross_platform_formats_only,
+ ) as f:
+ assert f.frames >= 0
+ assert f.read(f.frames).shape[1] == f.frames
+
+
@pytest.mark.parametrize("quality", list(range(9)))
@pytest.mark.parametrize("chunk_duration", [16, 1024, 2048, 1024 * 1024])
@pytest.mark.parametrize("granularity", [1, 16, 17, 1024, 1025])