jiaaro / pydub

Manipulate audio with a simple and easy high level interface
http://pydub.com
MIT License
8.96k stars 1.05k forks source link

Fix imports of AudioSegments in stereo_to_ms and ms_to_stereo #707

Open Ghostkeeper opened 1 year ago

Ghostkeeper commented 1 year ago

There is no symbol AudioSegment defined in the stereo_to_ms and ms_to_stereo functions. Calling them results in:

NameError: name 'AudioSegment' is not defined. Did you mean: 'audio_segment'?

We cannot import AudioSegment at the top of the module, so we must import it inside of this function.

Here is some example code that triggers the error. This is more or less how I discovered the mistake.

from pydub import AudioSegment
import pydub.scipy_effects
song = AudioSegment.from_mp3("song.mp3")
song = song.eq(100, gain_dB=4, channel_mode="M+S")  # This channel mode causes stereo_to_ms and ms_to_stereo to be called.

This error was introduced with this change: https://github.com/jiaaro/pydub/pull/492